mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-54751 phpunit: Support adhoc module and section deletion in phpunit
Created a new phpunit util function run_all_adhoc_tasks which runs any pending tasks, for use in unit tests. Added new recyclebin and course unit tests covering the new functionality.
This commit is contained in:
parent
2f6e0d92b7
commit
3704ff8cde
3 changed files with 313 additions and 0 deletions
|
@ -819,4 +819,21 @@ class phpunit_util extends testing_util {
|
|||
return 'en_AU.UTF-8';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes all adhoc tasks in the queue. Useful for testing asynchronous behaviour.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function run_all_adhoc_tasks() {
|
||||
$now = time();
|
||||
while (($task = \core\task\manager::get_next_adhoc_task($now)) !== null) {
|
||||
try {
|
||||
$task->execute();
|
||||
\core\task\manager::adhoc_task_complete($task);
|
||||
} catch (Exception $e) {
|
||||
\core\task\manager::adhoc_task_failed($task);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue