[BUGFIX] Unit test fails with broken timezone
authorChristian Kuhn <lolli@schwarzbu.ch>
Fri, 8 Feb 2013 14:52:09 +0000 (15:52 +0100)
committerDaniel Hürtgen <daniel@higidi.de>
Fri, 8 Feb 2013 15:23:09 +0000 (16:23 +0100)
Commit 87eba80ea3d785 introduced tests that set the default
timezone. This fails due to a typo "Europa" -> "Europe"
Additionally, one of the tests is splitted to using a data
provider.

Change-Id: I893201b8dc0180a458a65f6fd65c9f2104f3e980
Fixes: #45285
Related: #12769
Related: #43363
Related: #9174
Releases: 6.1, 6.0, 4.7, 4.6, 4.5
Reviewed-on: https://review.typo3.org/18119
Reviewed-by: Daniel Hürtgen
Tested-by: Daniel Hürtgen
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Format/DateViewHelperTest.php

index b88d1fc..e376cdf 100644 (file)
@@ -108,32 +108,47 @@ class DateViewHelperTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
        }
 
        /**
+        * Data provider for viewHelperRespectsDefaultTimezoneForIntegerTimestamp
+        *
+        * @return array
+        */
+       public function viewHelperRespectsDefaultTimezoneForIntegerTimestampDataProvider() {
+               return array(
+                       'Europe/Berlin' => array(
+                               'Europe/Berlin',
+                               '2013-02-03 12:40',
+                       ),
+                       'Asia/Riyadh' => array(
+                               'Asia/Riyadh',
+                               '2013-02-03 14:40',
+                       ),
+               );
+       }
+
+       /**
         * @test
+        * @dataProvider viewHelperRespectsDefaultTimezoneForIntegerTimestampDataProvider
         */
-       public function viewHelperRespectsDefaultTimezoneForIntegerTimestamp() {
+       public function viewHelperRespectsDefaultTimezoneForIntegerTimestamp($timezone, $expected) {
                $viewHelper = $this->getMock('TYPO3\\CMS\\Fluid\\ViewHelpers\\Format\\DateViewHelper', array('renderChildren'));
 
                $date = 1359891658; // 2013-02-03 11:40 UTC
                $format = 'Y-m-d H:i';
 
-               date_default_timezone_set('Europa/Berlin');
-               $expected = '2013-02-03 12:40';
-               $this->assertEquals($expected, $viewHelper->render($date, $format));
-
-               date_default_timezone_set('Asia/Riyadh');
-               $expected = '2013-02-03 14:40';
+               date_default_timezone_set($timezone);
                $this->assertEquals($expected, $viewHelper->render($date, $format));
        }
 
        /**
         * @test
+        * @TODO: Split the single sets to a data provider
         */
        public function viewHelperRespectsDefaultTimezoneForStringTimestamp() {
                $viewHelper = $this->getMock('TYPO3\\CMS\\Fluid\\ViewHelpers\\Format\\DateViewHelper', array('renderChildren'));
 
                $format = 'Y-m-d H:i';
 
-               date_default_timezone_set('Europa/Berlin');
+               date_default_timezone_set('Europe/Berlin');
                $date = '@1359891658'; // 2013-02-03 11:40 UTC
                $expected = '2013-02-03 12:40';
                $this->assertEquals($expected, $viewHelper->render($date, $format));
@@ -154,6 +169,7 @@ class DateViewHelperTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
 
        /**
         * @test
+        * @TODO: Split the single sets to a data provider
         */
        public function dateViewHelperFormatsDateLocalized() {
                $viewHelper = $this->getMock('TYPO3\\CMS\\Fluid\\ViewHelpers\\Format\\DateViewHelper', array('renderChildren'));