From 814114ab8eda5d383f4c620f3854cfefcdb6895d Mon Sep 17 00:00:00 2001 From: Thomas Müller Date: Mon, 22 Sep 2014 15:03:28 +0200 Subject: enhance formatDate function to accept an optional argument containing the time zone --- tests/lib/util.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'tests/lib') diff --git a/tests/lib/util.php b/tests/lib/util.php index 8964f9f2666..e43b6309eae 100644 --- a/tests/lib/util.php +++ b/tests/lib/util.php @@ -37,6 +37,30 @@ class Test_Util extends PHPUnit_Framework_TestCase { $this->assertEquals($expected, $result); } + function testFormatDateWithTZ() { + date_default_timezone_set("UTC"); + + $result = OC_Util::formatDate(1350129205, false, 'Europe/Berlin'); + $expected = 'October 13, 2012 13:53'; + $this->assertEquals($expected, $result); + } + + /** + * @expectedException Exception + */ + function testFormatDateWithInvalidTZ() { + OC_Util::formatDate(1350129205, false, 'Mordor/Barad-dûr'); + } + + function testFormatDateWithTZFromSession() { + date_default_timezone_set("UTC"); + + \OC::$server->getSession()->set('timezone', 3); + $result = OC_Util::formatDate(1350129205, false); + $expected = 'October 13, 2012 14:53'; + $this->assertEquals($expected, $result); + } + function testCallRegister() { $result = strlen(OC_Util::callRegister()); $this->assertEquals(30, $result); -- cgit v1.2.3