From 0058ac47f3bcad382c8d61d7bd0672d01d10134f Mon Sep 17 00:00:00 2001 From: Michael Oehlhof <typo3@oehlhof.de> Date: Sat, 26 Sep 2015 23:24:47 +0200 Subject: [PATCH] [TASK] Write unit tests for stdWrapValue() 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> --- .../ContentObjectRendererTest.php | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php b/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php index 4b0161e92e2c..7ca2353c1873 100644 --- a/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php +++ b/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php @@ -1581,6 +1581,71 @@ class ContentObjectRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase { $this->assertEquals($expected, $result); } + /** + * 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 -- GitLab