MDL-54751 behat: Support for adhoc module and section deletion in behat
Introduced new behat step for running all pending adhoc tasks and modified the relavant behat tests.
This commit is contained in:
@@ -58,6 +58,7 @@ Feature: Backup user data
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I delete "Quiz 1" activity
|
||||
And I run all adhoc tasks
|
||||
And I navigate to "Recycle bin" node in "Course administration"
|
||||
And I should see "Quiz 1"
|
||||
And I click on "Restore" "link" in the "region-main" "region"
|
||||
|
||||
@@ -69,6 +69,7 @@ Feature: Basic recycle bin functionality
|
||||
| Assignment name | Test assign |
|
||||
| Description | Test |
|
||||
And I delete "Test assign" activity
|
||||
And I run all adhoc tasks
|
||||
And I navigate to "Recycle bin" node in "Course administration"
|
||||
When I click on "Delete" "link"
|
||||
Then I should see "Are you sure you want to delete the selected item from the recycle bin?"
|
||||
@@ -92,6 +93,7 @@ Feature: Basic recycle bin functionality
|
||||
| Description | Test 2 |
|
||||
And I delete "Test assign 1" activity
|
||||
And I delete "Test assign 2" activity
|
||||
And I run all adhoc tasks
|
||||
And I navigate to "Recycle bin" node in "Course administration"
|
||||
And I should see "Test assign 1"
|
||||
And I should see "Test assign 2"
|
||||
|
||||
@@ -114,7 +114,8 @@ abstract class base_logger implements checksumable {
|
||||
|
||||
public final function process($message, $level, $options = null) {
|
||||
$result = true;
|
||||
if ($this->level != backup::LOG_NONE && $this->level >= $level) { // Perform action conditionally
|
||||
if ($this->level != backup::LOG_NONE && $this->level >= $level
|
||||
&& !(defined('BEHAT_TEST') && BEHAT_TEST)) { // Perform action conditionally.
|
||||
$result = $this->action($message, $level, $options);
|
||||
}
|
||||
if ($result === false) { // Something was wrong, stop the chain
|
||||
|
||||
@@ -194,6 +194,7 @@ Feature: View structural changes in recent activity block
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I delete "ForumUpdated" activity
|
||||
And I run all adhoc tasks
|
||||
And I log out
|
||||
And I wait "1" seconds
|
||||
# Students 1 and 2 see that forum was deleted
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user