From 70a9bf863beb3fda30f90cb0bef0b75f29ba38cd Mon Sep 17 00:00:00 2001 From: Damyon Wiese Date: Tue, 2 Apr 2013 22:00:56 +0800 Subject: [PATCH] MDL-38840 Statslib - Fix failing unit tests on ci server (DST change) --- lib/tests/statslib_test.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/tests/statslib_test.php b/lib/tests/statslib_test.php index 2e79f80fce1..48d1b9162b1 100644 --- a/lib/tests/statslib_test.php +++ b/lib/tests/statslib_test.php @@ -327,7 +327,8 @@ class statslib_daily_testcase extends advanced_testcase { $CFG->statsfirstrun = 'all'; // Allow 1 second difference in case we cross a second boundary. - $this->assertLessThanOrEqual(1, stats_get_start_from('daily') - ($time - (3 * 24 * 3600)), 'All start time'); + // Note: within 3 days of a DST change - -3 days != 3 * 24 hours (it may be more or less). + $this->assertLessThanOrEqual(1, stats_get_start_from('daily') - strtotime('-3 days', $time), 'All start time'); $this->prepare_db($dataset[0], array('log')); $records = $DB->get_records('log'); @@ -335,7 +336,7 @@ class statslib_daily_testcase extends advanced_testcase { $this->assertEquals($day + 14410, stats_get_start_from('daily'), 'Log entry start'); $CFG->statsfirstrun = 'none'; - $this->assertLessThanOrEqual(1, stats_get_start_from('daily') - ($time - (3 * 24 * 3600)), 'None start time'); + $this->assertLessThanOrEqual(1, stats_get_start_from('daily') - strtotime('-3 days', $time), 'None start time'); $CFG->statsfirstrun = 14515200; $this->assertLessThanOrEqual(1, stats_get_start_from('daily') - ($time - (14515200)), 'Specified start time');