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.
This commit is contained in:
Eloy Lafuente (stronk7) 2015-03-31 01:21:18 +02:00
parent bdd48b459e
commit 68632b6d80

View File

@ -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.