[TASK] Write unit tests for stdWrap_trim() and stdWrap_intval() 90/43590/2
authorMichael Oehlhof <typo3@oehlhof.de>
Sun, 27 Sep 2015 11:10:13 +0000 (13:10 +0200)
committerTymoteusz Motylewski <t.motylewski@gmail.com>
Sun, 27 Sep 2015 12:21:05 +0000 (14:21 +0200)
Write unit tests for ContentObjectRenderer->stdWrap_trim()
and ContentObjectRenderer->stdWrap_intval()

Resolves: #70131
Releases: master
Change-Id: I37cb632c2a2aad284d5ec42cff500e14d022fcd8
Reviewed-on: http://review.typo3.org/43590
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
Tested-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php

index 7ca2353..d899f18 100644 (file)
@@ -905,6 +905,94 @@ class ContentObjectRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        /**
         * @return array
         */
+       public function stdWrap_trimDataProvider() {
+               return array(
+                       'trimstring' => array(
+                               'trimstring',
+                               'trimstring',
+                       ),
+                       'trim string with space inside' => array(
+                               'trim string',
+                               'trim string',
+                       ),
+                       'trim string with space at the begin and end' => array(
+                               ' trim string ',
+                               'trim string',
+                       ),
+               );
+       }
+
+       /**
+        * Test for the stdWrap function "trim"
+        *
+        * @param string $content
+        * @param string $expected
+        *
+        * @dataProvider stdWrap_trimDataProvider
+        * @test
+        */
+       public function stdWrap_trim($content, $expected) {
+               $result = $this->subject->stdWrap_trim($content);
+               $this->assertEquals($expected, $result);
+       }
+
+       /**
+        * @return array
+        */
+       public function stdWrap_intvalDataProvider() {
+               return array(
+                       'number' => array(
+                               '123',
+                               123,
+                       ),
+                       'float' => array(
+                               '123.45',
+                               123,
+                       ),
+                       'string' => array(
+                               'string',
+                               0,
+                       ),
+                       'zero' => array(
+                               '0',
+                               0,
+                       ),
+                       'empty' => array(
+                               '',
+                               0,
+                       ),
+                       'NULL' => array(
+                               NULL,
+                               0,
+                       ),
+                       'bool TRUE' => array(
+                               TRUE,
+                               1,
+                       ),
+                       'bool FALSE' => array(
+                               FALSE,
+                               0,
+                       ),
+               );
+       }
+
+       /**
+        * Test for the stdWrap function "intval"
+        *
+        * @param string $content
+        * @param int $expected
+        *
+        * @dataProvider stdWrap_intvalDataProvider
+        * @test
+        */
+       public function stdWrap_intval($content, $expected) {
+               $result = $this->subject->stdWrap_intval($content);
+               $this->assertEquals($expected, $result);
+       }
+
+       /**
+        * @return array
+        */
        public function stdWrap_strPadDataProvider() {
                return array(
                        'pad string with default settings and length 10' => array(