MDL-78738 core_testing: Add helper to run adhoc tasks

This commit is contained in:
Andrew Nicols 2023-07-21 15:07:18 +08:00
parent a1d5d1b2f7
commit 235d5b9b72
No known key found for this signature in database
GPG Key ID: 6D1E3157C8CFBF14

View File

@ -719,4 +719,16 @@ abstract class advanced_testcase extends base_testcase {
}
$tasks->close();
}
/**
* Run adhoc tasks.
*/
protected function run_all_adhoc_tasks(): void {
// Run the adhoc task.
while ($task = \core\task\manager::get_next_adhoc_task(time())) {
$task->execute();
\core\task\manager::adhoc_task_complete($task);
}
}
}