diff options
Diffstat (limited to 'tests/lib/util.php')
-rw-r--r-- | tests/lib/util.php | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/tests/lib/util.php b/tests/lib/util.php index 3bb4b47c09c..1a2cb09f38d 100644 --- a/tests/lib/util.php +++ b/tests/lib/util.php @@ -41,7 +41,7 @@ class Test_Util extends \Test\TestCase { date_default_timezone_set("UTC"); $result = OC_Util::formatDate(1350129205, false, 'Europe/Berlin'); - $expected = 'October 13, 2012 at 1:53:25 PM GMT+0'; + $expected = 'October 13, 2012 at 1:53:25 PM GMT+2'; $this->assertEquals($expected, $result); } @@ -55,10 +55,22 @@ class Test_Util extends \Test\TestCase { function testFormatDateWithTZFromSession() { date_default_timezone_set("UTC"); + $oldDateTimeFormatter = \OC::$server->query('DateTimeFormatter'); \OC::$server->getSession()->set('timezone', 3); + $newDateTimeFormatter = new \OC\DateTimeFormatter(\OC::$server->getTimeZone(), new \OC_L10N('lib', 'en')); + $this->setDateFormatter($newDateTimeFormatter); + $result = OC_Util::formatDate(1350129205, false); - $expected = 'October 13, 2012 at 2:53:25 PM GMT+0'; + $expected = 'October 13, 2012 at 2:53:25 PM GMT+3'; $this->assertEquals($expected, $result); + + $this->setDateFormatter($oldDateTimeFormatter); + } + + protected function setDateFormatter($formatter) { + \OC::$server->registerService('DateTimeFormatter', function ($c) use ($formatter) { + return $formatter; + }); } function testCallRegister() { |