diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2014-09-22 15:03:28 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2014-09-22 15:03:28 +0200 |
commit | 814114ab8eda5d383f4c620f3854cfefcdb6895d (patch) | |
tree | e80442b93a34f22fa85cc6fbedd233954cd6f889 /tests | |
parent | f4eae03f20674423cbe9034fdbeb30125157e6fc (diff) | |
download | nextcloud-server-814114ab8eda5d383f4c620f3854cfefcdb6895d.tar.gz nextcloud-server-814114ab8eda5d383f4c620f3854cfefcdb6895d.zip |
enhance formatDate function to accept an optional argument containing the time zone
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/util.php | 24 |
1 files changed, 24 insertions, 0 deletions
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); |