]> source.dussan.org Git - nextcloud-server.git/commitdiff
Select the timezone on the right timestamp and assert it
authorJoas Schilling <nickvergessen@owncloud.com>
Tue, 7 Apr 2015 08:13:51 +0000 (10:13 +0200)
committerJoas Schilling <nickvergessen@owncloud.com>
Tue, 7 Apr 2015 08:13:51 +0000 (10:13 +0200)
tests/lib/util.php

index 49399c8cf0183a791b0a53dc021ebe39b6a40df9..e52a9fcc618f087e53b79229e558a310033428ea 100644 (file)
@@ -54,24 +54,27 @@ class Test_Util extends \Test\TestCase {
 
        public function formatDateWithTZFromSessionData() {
                return array(
-                       array(3, 'October 13, 2012 at 2:53:25 PM GMT+3'),
-                       array(15, 'October 13, 2012 at 11:53:25 AM GMT+0'),
-                       array(-13, 'October 13, 2012 at 11:53:25 AM GMT+0'),
-                       array(9.5, 'October 13, 2012 at 9:23:25 PM GMT+9:30'),
-                       array(-4.5, 'October 13, 2012 at 7:23:25 AM GMT-4:30'),
-                       array(15.5, 'October 13, 2012 at 11:53:25 AM GMT+0'),
+                       array(3, 'October 13, 2012 at 2:53:25 PM GMT+3', 'Etc/GMT-3'),
+                       array(15, 'October 13, 2012 at 11:53:25 AM GMT+0', 'UTC'),
+                       array(-13, 'October 13, 2012 at 11:53:25 AM GMT+0', 'UTC'),
+                       array(9.5, 'October 13, 2012 at 9:23:25 PM GMT+9:30', 'Australia/Darwin'),
+                       array(-4.5, 'October 13, 2012 at 7:23:25 AM GMT-4:30', 'America/Caracas'),
+                       array(15.5, 'October 13, 2012 at 11:53:25 AM GMT+0', 'UTC'),
                );
        }
 
        /**
         * @dataProvider formatDateWithTZFromSessionData
         */
-       function testFormatDateWithTZFromSession($offset, $expected) {
+       function testFormatDateWithTZFromSession($offset, $expected, $expectedTimeZone) {
                date_default_timezone_set("UTC");
 
                $oldDateTimeFormatter = \OC::$server->query('DateTimeFormatter');
                \OC::$server->getSession()->set('timezone', $offset);
-               $newDateTimeFormatter = new \OC\DateTimeFormatter(\OC::$server->getDateTimeZone()->getTimeZone(), new \OC_L10N('lib', 'en'));
+
+               $selectedTimeZone = \OC::$server->getDateTimeZone()->getTimeZone(1350129205);
+               $this->assertEquals($expectedTimeZone, $selectedTimeZone->getName());
+               $newDateTimeFormatter = new \OC\DateTimeFormatter($selectedTimeZone, new \OC_L10N('lib', 'en'));
                $this->setDateFormatter($newDateTimeFormatter);
 
                $result = OC_Util::formatDate(1350129205, false);