Skip to content

Commit

Permalink
MDL-45813 Fix variable name in scheduled task
Browse files Browse the repository at this point in the history
  • Loading branch information
mudrd8mz committed Jun 9, 2014
1 parent e7ea6b9 commit dc56173
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/classes/task/scheduled_task.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ public function get_next_scheduled_time() {
// otherwise - choose the soonest (see man 5 cron).
if ($this->dayofweek == '*') {
$daysincrement = $daysincrementbymonth;
} else if ($this->dayofmonth == '*') {
} else if ($this->day == '*') {
$daysincrement = $daysincrementbyweek;
} else {
// Take the smaller increment of days by month or week.
Expand Down
22 changes: 22 additions & 0 deletions lib/tests/scheduled_task_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,28 @@ public function test_get_next_scheduled_time() {
$testclass->set_disabled(true);
$nexttime = $testclass->get_next_scheduled_time();
$this->assertEquals($nexttenminutes, $nexttime, 'Next scheduled time is in 10 minutes.');

// Test hourly job executed on Sundays only.
$testclass = new \core\task\scheduled_test_task();
$testclass->set_minute('0');
$testclass->set_day_of_week('7');

$nexttime = $testclass->get_next_scheduled_time();

$this->assertEquals(7, date('N', $nexttime));
$this->assertEquals(0, date('i', $nexttime));

// Test monthly job
$testclass = new \core\task\scheduled_test_task();
$testclass->set_minute('32');
$testclass->set_hour('0');
$testclass->set_day('1');

$nexttime = $testclass->get_next_scheduled_time();

$this->assertEquals(32, date('i', $nexttime));
$this->assertEquals(0, date('G', $nexttime));
$this->assertEquals(1, date('j', $nexttime));
}

public function test_timezones() {
Expand Down

0 comments on commit dc56173

Please sign in to comment.