Skip to content

Commit

Permalink
MDL-47572 libraries: modify unittest to avoid random timing fail
Browse files Browse the repository at this point in the history
Thanks to Nigel Cunningham
  • Loading branch information
marinaglancy committed Oct 8, 2014
1 parent 6597413 commit 54f7d2d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/tests/cronlib_test.php
Expand Up @@ -43,7 +43,7 @@ public function cron_delete_from_temp_provider() {
$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;

Expand All @@ -54,8 +54,8 @@ public function cron_delete_from_temp_provider() {
// 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);
Expand Down

0 comments on commit 54f7d2d

Please sign in to comment.