diff --git a/Core/snippet-bootstrap.php b/Core/snippet-bootstrap.php index c36fafda5136..b53df247d3c9 100644 --- a/Core/snippet-bootstrap.php +++ b/Core/snippet-bootstrap.php @@ -3,3 +3,5 @@ use Google\Cloud\Core\Testing\TestHelpers; TestHelpers::snippetBootstrap(); + +date_default_timezone_set('UTC'); diff --git a/Core/tests/Unit/TimestampTest.php b/Core/tests/Unit/TimestampTest.php index 6af178227228..994509debad0 100644 --- a/Core/tests/Unit/TimestampTest.php +++ b/Core/tests/Unit/TimestampTest.php @@ -208,4 +208,28 @@ public function timestampArrays() ] ]; } + + /** + * @dataProvider timezones + */ + public function testTimezones($tz) + { + $time = new \DateTimeImmutable('now', new \DateTimeZone($tz)); + $timestamp = new Timestamp($time); + + $utc = $time->setTimeZone(new \DateTimeZone('UTC')); + $utcTs = new Timestamp($utc); + + $this->assertEquals($utcTs->formatAsString(), $timestamp->formatAsString()); + } + + public function timezones() + { + return [ + ['America/Detroit'], + ['Australia/Sydney'], + ['Pacific/Guam'], + ['Africa/Johannesburg'], + ]; + } } diff --git a/Core/unit-bootstrap.php b/Core/unit-bootstrap.php new file mode 100644 index 000000000000..f11c03886df4 --- /dev/null +++ b/Core/unit-bootstrap.php @@ -0,0 +1,3 @@ + - + */tests/Unit