mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
Merge branch 'MDL-54751-master-v5' of https://github.com/snake/moodle
This commit is contained in:
commit
90abff01b3
25 changed files with 725 additions and 25 deletions
|
@ -1001,6 +1001,43 @@ class behat_general extends behat_base {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs all ad-hoc tasks in the queue.
|
||||
*
|
||||
* This is faster and more reliable than running cron (running cron won't
|
||||
* work more than once in the same test, for instance). However it is
|
||||
* a little less 'realistic'.
|
||||
*
|
||||
* While the task is running, we suppress mtrace output because it makes
|
||||
* the Behat result look ugly.
|
||||
*
|
||||
* @Given /^I run all adhoc tasks$/
|
||||
* @throws DriverException
|
||||
*/
|
||||
public function i_run_all_adhoc_tasks() {
|
||||
// Do setup for cron task.
|
||||
cron_setup_user();
|
||||
|
||||
// Run tasks. Locking is handled by get_next_adhoc_task.
|
||||
$now = time();
|
||||
ob_start(); // Discard task output as not appropriate for Behat output!
|
||||
while (($task = \core\task\manager::get_next_adhoc_task($now)) !== null) {
|
||||
|
||||
try {
|
||||
$task->execute();
|
||||
|
||||
// Mark task complete.
|
||||
\core\task\manager::adhoc_task_complete($task);
|
||||
} catch (Exception $e) {
|
||||
// Mark task failed and throw exception.
|
||||
\core\task\manager::adhoc_task_failed($task);
|
||||
ob_end_clean();
|
||||
throw new DriverException('An adhoc task failed', 0, $e);
|
||||
}
|
||||
}
|
||||
ob_end_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that an element and selector type exists in another element and selector type on the current page.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue