From 122edcd0c1b652f25c36c52cc7541eb62695bf37 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 20 Oct 2016 15:11:01 +0200 Subject: Make sure all tests use the TestCase method to overwrite services Signed-off-by: Joas Schilling --- tests/lib/UtilTest.php | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'tests/lib/UtilTest.php') diff --git a/tests/lib/UtilTest.php b/tests/lib/UtilTest.php index 619963a2abf..a1671191ab8 100644 --- a/tests/lib/UtilTest.php +++ b/tests/lib/UtilTest.php @@ -87,24 +87,17 @@ class UtilTest extends \Test\TestCase { function testFormatDateWithTZFromSession($offset, $expected, $expectedTimeZone) { date_default_timezone_set("UTC"); - $oldDateTimeFormatter = \OC::$server->query('DateTimeFormatter'); \OC::$server->getSession()->set('timezone', $offset); $selectedTimeZone = \OC::$server->getDateTimeZone()->getTimeZone(1350129205); $this->assertEquals($expectedTimeZone, $selectedTimeZone->getName()); $newDateTimeFormatter = new \OC\DateTimeFormatter($selectedTimeZone, new \OC_L10N('lib', 'en')); - $this->setDateFormatter($newDateTimeFormatter); + $this->overwriteService('DateTimeFormatter', $newDateTimeFormatter); $result = OC_Util::formatDate(1350129205, false); $this->assertEquals($expected, $result); - $this->setDateFormatter($oldDateTimeFormatter); - } - - protected function setDateFormatter($formatter) { - \OC::$server->registerService('DateTimeFormatter', function ($c) use ($formatter) { - return $formatter; - }); + $this->restoreService('DateTimeFormatter'); } function testSanitizeHTML() { -- cgit v1.2.3