mirror of
https://github.com/moodle/moodle.git
synced 2025-04-15 05:25:08 +02:00
Merge branch 'MDL-45813-scheduled_task' of git://github.com/mudrd8mz/moodle
This commit is contained in:
commit
4422b08068
@ -340,7 +340,7 @@ abstract class scheduled_task extends task_base {
|
||||
// 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.
|
||||
|
@ -90,6 +90,28 @@ class core_scheduled_task_testcase extends advanced_testcase {
|
||||
$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() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user