summaryrefslogtreecommitdiffstats
path: root/tests/lib/util.php
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2014-11-24 16:37:04 +0100
committerJoas Schilling <nickvergessen@gmx.de>2014-12-10 11:58:56 +0100
commit4d232e536eb03895863c0d7d7fe703c41d433f70 (patch)
tree2adb86d986c986f4c34fac9fedb287f9a51191d5 /tests/lib/util.php
parent681caf882a5f28b0b6f7cb9a1f16b3dea26ff5f2 (diff)
downloadnextcloud-server-4d232e536eb03895863c0d7d7fe703c41d433f70.tar.gz
nextcloud-server-4d232e536eb03895863c0d7d7fe703c41d433f70.zip
Deprecate Util::formatDate()
Make DateTimeFormatter a service and adjust tests that have been inaccurate
Diffstat (limited to 'tests/lib/util.php')
-rw-r--r--tests/lib/util.php16
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() {