mirror of
https://github.com/moodle/moodle.git
synced 2025-08-07 01:46:45 +02:00
Merge branch 'MDL-50532-master' of git://github.com/FMCorz/moodle
This commit is contained in:
commit
ac41247254
2 changed files with 55 additions and 1 deletions
|
@ -217,6 +217,47 @@ class core_scheduled_task_testcase extends advanced_testcase {
|
|||
$this->assertEquals($initcount, $finalcount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that the reset function deletes old tasks.
|
||||
*/
|
||||
public function test_reset_scheduled_tasks_for_component_delete() {
|
||||
global $DB;
|
||||
$this->resetAfterTest(true);
|
||||
|
||||
$count = $DB->count_records('task_scheduled', array('component' => 'moodle'));
|
||||
$allcount = $DB->count_records('task_scheduled');
|
||||
|
||||
$task = new \core\task\scheduled_test_task();
|
||||
$task->set_component('moodle');
|
||||
$record = \core\task\manager::record_from_scheduled_task($task);
|
||||
$DB->insert_record('task_scheduled', $record);
|
||||
$this->assertTrue($DB->record_exists('task_scheduled', array('classname' => '\core\task\scheduled_test_task',
|
||||
'component' => 'moodle')));
|
||||
|
||||
$task = new \core\task\scheduled_test2_task();
|
||||
$task->set_component('moodle');
|
||||
$record = \core\task\manager::record_from_scheduled_task($task);
|
||||
$DB->insert_record('task_scheduled', $record);
|
||||
$this->assertTrue($DB->record_exists('task_scheduled', array('classname' => '\core\task\scheduled_test2_task',
|
||||
'component' => 'moodle')));
|
||||
|
||||
$aftercount = $DB->count_records('task_scheduled', array('component' => 'moodle'));
|
||||
$afterallcount = $DB->count_records('task_scheduled');
|
||||
|
||||
$this->assertEquals($count + 2, $aftercount);
|
||||
$this->assertEquals($allcount + 2, $afterallcount);
|
||||
|
||||
// Now check that the right things were deleted.
|
||||
\core\task\manager::reset_scheduled_tasks_for_component('moodle');
|
||||
|
||||
$this->assertEquals($count, $DB->count_records('task_scheduled', array('component' => 'moodle')));
|
||||
$this->assertEquals($allcount, $DB->count_records('task_scheduled'));
|
||||
$this->assertFalse($DB->record_exists('task_scheduled', array('classname' => '\core\task\scheduled_test2_task',
|
||||
'component' => 'moodle')));
|
||||
$this->assertFalse($DB->record_exists('task_scheduled', array('classname' => '\core\task\scheduled_test_task',
|
||||
'component' => 'moodle')));
|
||||
}
|
||||
|
||||
public function test_get_next_scheduled_task() {
|
||||
global $DB;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue