Merge branch 'MDL-54751-master-v5' of https://github.com/snake/moodle

This commit is contained in:
David Monllao 2016-11-07 08:55:44 +08:00
commit 90abff01b3
25 changed files with 725 additions and 25 deletions

View file

@ -822,4 +822,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);
}
}
}
}