Skip to content

Commit

Permalink
TimeTest for createFromTimestamp with timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
Toto Prayogo committed Jan 18, 2022
1 parent 279e1b5 commit 6682e25
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/system/I18n/TimeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,18 @@ public function testCreateFromTimestamp()
$this->assertSame(date('2017-03-18 00:00:00'), $time->toDateTimeString());
}

public function testCreateFromTimestampWithTimezone()
{
// Se the timezone temporarily to UTC to make sure the test timestamp is correct
date_default_timezone_set('UTC');

$timestamp = strtotime('2017-03-18 midnight'); // in UTC

$time = Time::createFromTimestamp($timestamp, 'Asia/Jakarta'); // UTC +7

$this->assertSame(date('2017-03-18 07:00:00'), $time->toDateTimeString());
}

public function testTestNow()
{
$this->assertFalse(Time::hasTestNow());
Expand Down

0 comments on commit 6682e25

Please sign in to comment.