From 391f8b395a3f02a6ee25b09fbeb1c95deb04e702 Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Thu, 1 Nov 2012 00:28:59 +0100 Subject: [PATCH 1/1] MDL-36315 backup: reduce the DST tests failing-window This reduces the period of time that some of the unit tests for calculate_next_automated_backup() are failing right now (from 1week to just some hours around the DST changes). Note it's not the final solution because they will still fail when New_York or Brussels DST changes are about to happen, but to get this completely fixed we'll need to wait to switch from current custom TZ/DST support to PHP built-in one. --- backup/util/helper/tests/cronhelper_test.php | 26 +++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/backup/util/helper/tests/cronhelper_test.php b/backup/util/helper/tests/cronhelper_test.php index 7afd1be1d08..d0e92aff3a0 100644 --- a/backup/util/helper/tests/cronhelper_test.php +++ b/backup/util/helper/tests/cronhelper_test.php @@ -281,9 +281,13 @@ class backup_cron_helper_testcase extends advanced_testcase { $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 @@ class backup_cron_helper_testcase extends advanced_testcase { $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 @@ class backup_cron_helper_testcase extends advanced_testcase { 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 @@ class backup_cron_helper_testcase extends advanced_testcase { 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); -- 2.43.0