Permalink
Browse files

Merge branch 'MDL-36315_23' of git://github.com/stronk7/moodle into M…

…OODLE_23_STABLE
  • Loading branch information...
2 parents b5b882d + 391f8b3 commit 35ce18a8b106ac585810818d870099fa5a08c896 @danpoltawski danpoltawski committed Nov 1, 2012
Showing with 22 additions and 4 deletions.
  1. +22 −4 backup/util/helper/tests/cronhelper_test.php
@@ -281,9 +281,13 @@ public function test_next_automated_backup() {
$this->assertEquals(date('w-15:00', strtotime('tomorrow')), date('w-H:i', $next));
// Let's have a Belgian beer! (UTC+1 / UTC+2 DST).
+ // Warning: Some of these tests will fail if executed "around"
+ // 'Europe/Brussels' DST changes (last Sunday in March and
+ // last Sunday in October right now - 2012). Once Moodle
+ // moves to PHP TZ support this could be fixed properly.
date_default_timezone_set('Europe/Brussels');
$now = strtotime('18:00:00');
- $dst = date('I');
+ $dst = date('I', $now);
$timezone = -10.0; // 7am for the user.
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
@@ -321,9 +325,13 @@ public function test_next_automated_backup() {
$this->assertEquals($expected, date('w-H:i', $next));
// The big apple! (UTC-5 / UTC-4 DST).
+ // Warning: Some of these tests will fail if executed "around"
+ // 'America/New_York' DST changes (2nd Sunday in March and
+ // 1st Sunday in November right now - 2012). Once Moodle
+ // moves to PHP TZ support this could be fixed properly.
date_default_timezone_set('America/New_York');
$now = strtotime('18:00:00');
- $dst = date('I');
+ $dst = date('I', $now);
$timezone = -10.0; // 1pm for the user.
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
@@ -365,9 +373,14 @@ public function test_next_automated_backup() {
set_config('backup_auto_hour', '20', 'backup');
set_config('backup_auto_minute', '00', 'backup');
+ // Note: These tests should not fail because they are "unnafected"
+ // by DST changes, as far as execution always happens on Monday and
+ // Saturday and those week days are not, right now, the ones rulez
+ // to peform the DST changes (Sunday is). This may change if rules
+ // are modified in the future.
date_default_timezone_set('Europe/Brussels');
$now = strtotime('next Monday 18:00:00');
- $dst = date('I');
+ $dst = date('I', $now);
$timezone = -12.0; // 1pm for the user.
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);
@@ -404,9 +417,14 @@ public function test_next_automated_backup() {
set_config('backup_auto_hour', '02', 'backup');
set_config('backup_auto_minute', '00', 'backup');
+ // Note: These tests should not fail because they are "unnafected"
+ // by DST changes, as far as execution always happens on Monday and
+ // Saturday and those week days are not, right now, the ones rulez
+ // to peform the DST changes (Sunday is). This may change if rules
+ // are modified in the future.
date_default_timezone_set('America/New_York');
$now = strtotime('next Monday 04:00:00');
- $dst = date('I');
+ $dst = date('I', $now);
$timezone = -12.0; // 8pm for the user.
$next = backup_cron_automated_helper::calculate_next_automated_backup($timezone, $now);

0 comments on commit 35ce18a

Please sign in to comment.