From 322da50afeac4754ccc877ce58ea96384167a7b9 Mon Sep 17 00:00:00 2001 From: Michael Oehlhof <typo3@oehlhof.de> Date: Fri, 2 Oct 2015 06:06:05 +0200 Subject: [PATCH] [TASK] Add unit tests for stdWrap_date() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolves: #70287 Releases: master Change-Id: I1050bc805b57bc66ba45ffdb4ac014b898e1f3c8 Reviewed-on: http://review.typo3.org/43717 Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl> Tested-by: Wouter Wolters <typo3@wouterwolters.nl> Reviewed-by: Michael Oehlhof <typo3@oehlhof.de> Tested-by: Michael Oehlhof <typo3@oehlhof.de> Reviewed-by: Frank Nägler <frank.naegler@typo3.org> Tested-by: Frank Nägler <frank.naegler@typo3.org> --- .../ContentObjectRendererTest.php | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php b/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php index e2bf614fd851..24b9cd20223d 100644 --- a/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php +++ b/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php @@ -1655,6 +1655,64 @@ class ContentObjectRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase { $this->subject->getQuery('tt_content', $conf, TRUE); } + /** + * Data provider for the stdWrap_date test + * + * @return array multi-dimensional array with the second level like this: + * @see stdWrap_date + */ + public function stdWrap_dateDataProvider() { + return array( + 'given timestamp' => array( + 1443780000, // This is 2015-10-02 12:00 + array( + 'date' => 'd.m.Y', + ), + '02.10.2015', + ), + 'empty string' => array( + '', + array( + 'date' => 'd.m.Y', + ), + '02.10.2015', + ), + 'testing null' => array( + NULL, + array( + 'date' => 'd.m.Y', + ), + '02.10.2015', + ), + 'given timestamp return GMT' => array( + 1443780000, // This is 2015-10-02 12:00 + array( + 'date' => 'd.m.Y H:i:s', + 'date.' => array( + 'GMT' => TRUE, + ) + ), + '02.10.2015 10:00:00', + ), + ); + } + + /** + * @test + * @dataProvider stdWrap_dateDataProvider + * @param string|int|NULL $content + * @param array $conf + * @param string $expected + */ + public function stdWrap_date($content, $conf, $expected) { + // Set exec_time to a hard timestamp + $GLOBALS['EXEC_TIME'] = 1443780000; + + $result = $this->subject->stdWrap_date($content, $conf); + + $this->assertEquals($expected, $result); + } + /** * Data provider for the stdWrap_strftime test * -- GitLab