From 54f7d2d7f47f485c193661e88a3cf4d23c1b74b8 Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Wed, 8 Oct 2014 13:55:14 +1100 Subject: [PATCH] MDL-47572 libraries: modify unittest to avoid random timing fail Thanks to Nigel Cunningham --- lib/tests/cronlib_test.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/tests/cronlib_test.php b/lib/tests/cronlib_test.php index 66961114d5a..4d7a1b5e1a7 100644 --- a/lib/tests/cronlib_test.php +++ b/lib/tests/cronlib_test.php @@ -43,7 +43,7 @@ class cronlib_testcase extends basic_testcase { $time = 0; // Relative time stamps. Did you know data providers get executed during phpunit init? - $lastweekstime = -(7 * 24 * 60 * 60); + $lastweekstime = strtotime('-1 week') - time(); $beforelastweekstime = $lastweekstime - 60; $afterlastweekstime = $lastweekstime + 60; @@ -54,8 +54,8 @@ class cronlib_testcase extends basic_testcase { // New Directory to keep. $nodes[] = $this->generate_test_path('/dir1/dir1_2/', true, $time, true); - // Directory exactly 1 week old, keep. - $nodes[] = $this->generate_test_path('/dir2/', true, $lastweekstime, true); + // Directory a little less than 1 week old, keep. + $nodes[] = $this->generate_test_path('/dir2/', true, $afterlastweekstime, true); // Directory older than 1 week old, remove. $nodes[] = $this->generate_test_path('/dir3/', true, $beforelastweekstime, false); -- 2.43.0