[TASK] Write unit tests for stdWrapValue() 89/43589/3
authorMichael Oehlhof <typo3@oehlhof.de>
Sat, 26 Sep 2015 21:24:47 +0000 (23:24 +0200)
committerTymoteusz Motylewski <t.motylewski@gmail.com>
Sun, 27 Sep 2015 12:16:37 +0000 (14:16 +0200)
Write unit tests for ContentObjectRenderer->stdWrapValue()

Resolves: #70130
Releases: master
Change-Id: Idd9abae877d456ec6ed42b5da058dc551aedbb77
Reviewed-on: http://review.typo3.org/43589
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 4b0161e..7ca2353 100644 (file)
@@ -1582,6 +1582,71 @@ class ContentObjectRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        }
 
        /**
+        * Data provider for stdWrap_stdWrapValue test
+        *
+        * @return array
+        */
+       public function stdWrap_stdWrapValueDataProvider() {
+               return array(
+                       'only key returns value' => array(
+                               'ifNull',
+                               array(
+                                       'ifNull' => '1',
+                               ),
+                               '',
+                               '1',
+                       ),
+                       'array without key returns empty string' => array(
+                               'ifNull',
+                               array(
+                                       'ifNull.' => '1',
+                               ),
+                               '',
+                               '',
+                       ),
+                       'array without key returns default' => array(
+                               'ifNull',
+                               array(
+                                       'ifNull.' => '1',
+                               ),
+                               'default',
+                               'default',
+                       ),
+                       'non existing key returns default' => array(
+                               'ifNull',
+                               array(
+                                       'noTrimWrap' => 'test',
+                                       'noTrimWrap.' => '1',
+                               ),
+                               'default',
+                               'default',
+                       ),
+                       'existing key and array returns stdWrap' => array(
+                               'test',
+                               array(
+                                       'test' => 'value',
+                                       'test.' => array('case' => 'upper'),
+                               ),
+                               'default',
+                               'VALUE'
+                       ),
+               );
+       }
+
+       /**
+        * @param string $key
+        * @param array $configuration
+        * @param string $defaultValue
+        * @param string $expected
+        * @dataProvider stdWrap_stdWrapValueDataProvider
+        * @test
+        */
+       public function stdWrap_stdWrapValue($key, array $configuration, $defaultValue, $expected) {
+               $result = $this->subject->stdWrapValue($key, $configuration, $defaultValue);
+               $this->assertEquals($expected, $result);
+       }
+
+       /**
         * @param string|NULL $content
         * @param array $configuration
         * @param string $expected