Skip to content

Commit

Permalink
MDL-22183 lib: More unit tests for next day start.
Browse files Browse the repository at this point in the history
  • Loading branch information
abgreeve committed Aug 18, 2016
1 parent 3cdc35b commit 3b87339
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/tests/statslib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,22 @@ public function test_statslib_get_base_daily() {
public function test_statslib_get_next_day_start() {
$this->setTimezone(0);
$this->assertEquals(1272758400, stats_get_next_day_start(1272686410));

// Try setting timezone to some place in the US.
$this->setTimezone('America/New_York', 'America/New_York');
// Then set the time for midnight before daylight savings.
// 1425790800 is midnight in New York (2015-03-08) Daylight saving will occur in 2 hours time.
// 1425873600 is midnight the next day.
$this->assertEquals(1425873600, stats_get_next_day_start(1425790800));
$this->assertEquals(23, ((1425873600 - 1425790800) / 60 ) / 60);
// Then set the time for midnight before daylight savings ends.
// 1446350400 is midnight in New York (2015-11-01) Daylight saving will finish in 2 hours time.
// 1446440400 is midnight the next day.
$this->assertEquals(1446440400, stats_get_next_day_start(1446350400));
$this->assertEquals(25, ((1446440400 - 1446350400) / 60 ) / 60);
// The next day should be normal.
$this->assertEquals(1446526800, stats_get_next_day_start(1446440400));
$this->assertEquals(24, ((1446526800 - 1446440400) / 60 ) / 60);
}

/**
Expand Down

0 comments on commit 3b87339

Please sign in to comment.