From 68632b6d80f18106fd48f5f4ea28c3ec1f6dea67 Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Tue, 31 Mar 2015 01:21:18 +0200 Subject: [PATCH] MDL-47572 unit tests: make cronlib_testcase DST immune Disclaimer: I've assigned this commit to MDL-47572 because it's the issue where I've seen related changes. Since a couple of days ago, both CI servers were failing. A couple of days ago it was DST change in Europe/Madrid (that is the PHP default TZ used by them). Tests pass perfectly if the TZ is set to any other place not affected by DST (Australia/Perth, for example). Really the issue is a wrong mix of functions supporting DST and functions not supporting them. But, with current implementation (checking +-60 seconds around a time) and with a DST change in the middle... this unit tests was going to be failing for an entire week. And that's not acceptable for CIs. So, I've changed the intervals, to be bigger than 1h (exactly 1h1s), so they will be immune to the DST change/partial support. Ideally all operations should be working in the same way (with or without DST considered), but that's out from the scope of getting this test stable enough and passing. --- lib/tests/cronlib_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/tests/cronlib_test.php b/lib/tests/cronlib_test.php index 4d7a1b5e1a7..66b33a99dcd 100644 --- a/lib/tests/cronlib_test.php +++ b/lib/tests/cronlib_test.php @@ -44,8 +44,8 @@ class cronlib_testcase extends basic_testcase { // Relative time stamps. Did you know data providers get executed during phpunit init? $lastweekstime = strtotime('-1 week') - time(); - $beforelastweekstime = $lastweekstime - 60; - $afterlastweekstime = $lastweekstime + 60; + $beforelastweekstime = $lastweekstime - 3600 - 1; // At least 1h and 1s diff (make it DST immune). + $afterlastweekstime = $lastweekstime + 3600 + 1; // At least 1h and 1s diff (make it DST immune). $nodes = array(); // Really old directory to remove. -- 2.43.0