From 88a3f3b1d4e60fe2c389e586a9da5e0598bc80fd Mon Sep 17 00:00:00 2001 From: nathangray Date: Tue, 17 Oct 2017 15:40:05 +0200 Subject: [PATCH] Run test in UTC, so dates match our expectations --- api/src/test/DateTimeTest.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/api/src/test/DateTimeTest.php b/api/src/test/DateTimeTest.php index 79d1c4a5af..fb0ed51ffd 100644 --- a/api/src/test/DateTimeTest.php +++ b/api/src/test/DateTimeTest.php @@ -22,6 +22,7 @@ use PHPUnit\Framework\TestCase as TestCase; class DateTimeTest extends TestCase { protected static $usertime; + protected static $server_tz; /** * Work in server time, so tests match expectations @@ -32,6 +33,13 @@ class DateTimeTest extends TestCase { static::$usertime = DateTime::$user_timezone; + static::$server_tz = date_default_timezone_get(); + + // Set time to UTC time for consistency + DateTime::setUserPrefs('UTC'); + date_default_timezone_set('UTC'); + DateTime::$server_timezone = new \DateTimeZone('UTC'); + // Set user time to server time for consistency DateTime::setUserPrefs(date_default_timezone_get()); } @@ -39,6 +47,7 @@ class DateTimeTest extends TestCase { { // Reset DateTime::setUserPrefs(static::$usertime->getName()); + date_default_timezone_set(static::$server_tz); unset($GLOBALS['egw']); parent::tearDownAfterClass();