[TASK] Add unit tests for stdWrap_date() 17/43717/3
authorMichael Oehlhof <typo3@oehlhof.de>
Fri, 2 Oct 2015 04:06:05 +0000 (06:06 +0200)
committerFrank Nägler <frank.naegler@typo3.org>
Fri, 2 Oct 2015 11:35:03 +0000 (13:35 +0200)
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>
typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php

index e2bf614..24b9cd2 100644 (file)
@@ -1656,6 +1656,64 @@ class ContentObjectRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        }
 
        /**
+        * 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
         *
         * @return array multi-dimensional array with the second level like this: