Run test in UTC, so dates match our expectations

This commit is contained in:
nathangray 2017-10-17 15:40:05 +02:00
parent 6fad74c710
commit 88a3f3b1d4

View File

@ -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();