mirror of
https://github.com/moodle/moodle.git
synced 2025-04-24 18:04:43 +02:00
MDL-45935 tests: Specify step names during backup/restore tests
This commit is contained in:
parent
e7ea6b9a24
commit
87a37ebe6b
backup/util/ui/tests/behat
@ -18,7 +18,7 @@ Feature: Backup Moodle courses
|
||||
@javascript
|
||||
Scenario: Backup a course providing options
|
||||
When I backup "Course 1" course using this options:
|
||||
| Filename | test_backup.mbz |
|
||||
| Confirmation | Filename | test_backup.mbz |
|
||||
Then I should see "Restore"
|
||||
And I click on "Restore" "link" in the "test_backup.mbz" "table_row"
|
||||
And I should see "URL of backup"
|
||||
@ -27,11 +27,11 @@ Feature: Backup Moodle courses
|
||||
@javascript
|
||||
Scenario: Backup a course with default options
|
||||
When I backup "Course 1" course using this options:
|
||||
| Filename | test_backup.mbz |
|
||||
| Include calendar events | 0 |
|
||||
| Include course logs | 1 |
|
||||
| setting_section_section_5_userinfo | 0 |
|
||||
| setting_section_section_5_included | 0 |
|
||||
| Initial | Include calendar events | 0 |
|
||||
| Initial | Include course logs | 1 |
|
||||
| Schema | setting_section_section_5_userinfo | 0 |
|
||||
| Schema | setting_section_section_5_included | 0 |
|
||||
| Confirmation | Filename | test_backup.mbz |
|
||||
Then I should see "Restore"
|
||||
And I click on "Restore" "link" in the "test_backup.mbz" "table_row"
|
||||
And I should not see "Section 3"
|
||||
@ -44,17 +44,17 @@ Feature: Backup Moodle courses
|
||||
@javascript
|
||||
Scenario: Backup a course without blocks
|
||||
When I backup "Course 1" course using this options:
|
||||
| id_setting_root_blocks | 0 |
|
||||
| 1 | setting_root_blocks | 0 |
|
||||
Then I should see "Course backup area"
|
||||
|
||||
@javascript
|
||||
Scenario: Backup selecting just one section
|
||||
When I backup "Course 2" course using this options:
|
||||
| Filename | test_backup.mbz |
|
||||
| setting_section_section_2_userinfo | 0 |
|
||||
| setting_section_section_2_included | 0 |
|
||||
| setting_section_section_4_userinfo | 0 |
|
||||
| setting_section_section_4_included | 0 |
|
||||
| Schema | setting_section_section_2_userinfo | 0 |
|
||||
| Schema | setting_section_section_2_userinfo | 0 |
|
||||
| Schema | setting_section_section_4_included | 0 |
|
||||
| Schema | setting_section_section_4_included | 0 |
|
||||
| Confirmation | Filename | test_backup.mbz |
|
||||
Then I should see "Course backup area"
|
||||
And I click on "Restore" "link" in the "test_backup.mbz" "table_row"
|
||||
And I should not see "Section 2"
|
||||
|
@ -50,34 +50,31 @@ class behat_backup extends behat_base {
|
||||
* @param TableNode $options Backup options or false if no options provided
|
||||
*/
|
||||
public function i_backup_course_using_this_options($backupcourse, $options = false) {
|
||||
|
||||
// We can not use other steps here as we don't know where the provided data
|
||||
// table elements are used, and we need to catch exceptions contantly.
|
||||
|
||||
// Go to homepage.
|
||||
$this->getSession()->visit($this->locate_path('/'));
|
||||
$this->wait();
|
||||
|
||||
// Click the course link.
|
||||
$this->find_link($backupcourse)->click();
|
||||
$this->wait();
|
||||
|
||||
// Click the backup link.
|
||||
$this->find_link(get_string('backup'))->click();
|
||||
$this->wait();
|
||||
|
||||
// Initial settings.
|
||||
$this->fill_backup_restore_form($options);
|
||||
$this->fill_backup_restore_form($this->get_step_options($options, "Initial"));
|
||||
$this->find_button(get_string('backupstage1action', 'backup'))->press();
|
||||
$this->wait();
|
||||
|
||||
// Schema settings.
|
||||
$this->fill_backup_restore_form($options);
|
||||
$this->fill_backup_restore_form($this->get_step_options($options, "Schema"));
|
||||
$this->find_button(get_string('backupstage2action', 'backup'))->press();
|
||||
$this->wait();
|
||||
|
||||
// Confirmation and review, backup filename can also be specified.
|
||||
$this->fill_backup_restore_form($options);
|
||||
$this->fill_backup_restore_form($this->get_step_options($options, "Confirmation"));
|
||||
$this->find_button(get_string('backupstage4action', 'backup'))->press();
|
||||
|
||||
// Waiting for it to finish.
|
||||
@ -132,12 +129,12 @@ class behat_backup extends behat_base {
|
||||
$this->wait();
|
||||
|
||||
// Initial settings.
|
||||
$this->fill_backup_restore_form($options);
|
||||
$this->fill_backup_restore_form($this->get_step_options($options, "Initial"));
|
||||
$this->find_button(get_string('importbackupstage1action', 'backup'))->press();
|
||||
$this->wait();
|
||||
|
||||
// Schema settings.
|
||||
$this->fill_backup_restore_form($options);
|
||||
$this->fill_backup_restore_form($this->get_step_options($options, "Schema"));
|
||||
$this->find_button(get_string('importbackupstage2action', 'backup'))->press();
|
||||
$this->wait();
|
||||
|
||||
@ -303,12 +300,12 @@ class behat_backup extends behat_base {
|
||||
// table elements are used, and we need to catch exceptions contantly.
|
||||
|
||||
// Settings.
|
||||
$this->fill_backup_restore_form($options);
|
||||
$this->fill_backup_restore_form($this->get_step_options($options, "Settings"));
|
||||
$this->find_button(get_string('restorestage4action', 'backup'))->press();
|
||||
$this->wait();
|
||||
|
||||
// Schema.
|
||||
$this->fill_backup_restore_form($options);
|
||||
$this->fill_backup_restore_form($this->get_step_options($options, "Schema"));
|
||||
$this->find_button(get_string('restorestage8action', 'backup'))->press();
|
||||
$this->wait();
|
||||
|
||||
@ -341,23 +338,46 @@ class behat_backup extends behat_base {
|
||||
return;
|
||||
}
|
||||
|
||||
// Wait for the page to be loaded and the JS ready.
|
||||
$this->wait();
|
||||
|
||||
// If we find any of the provided options in the current form we should set the value.
|
||||
$datahash = $options->getRowsHash();
|
||||
foreach ($datahash as $locator => $value) {
|
||||
|
||||
try {
|
||||
$field = behat_field_manager::get_form_field_from_label($locator, $this);
|
||||
$field->set_value($value);
|
||||
|
||||
} catch (ElementNotFoundException $e) {
|
||||
// Next provided option then, this one should be part of another page's fields.
|
||||
}
|
||||
$field = behat_field_manager::get_form_field_from_label($locator, $this);
|
||||
$field->set_value($value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the options specific to this step of the backup/restore process.
|
||||
*
|
||||
* @param TableNode $options The options table to filter
|
||||
* @param string $step The name of the step
|
||||
* @return TableNode The filtered options table
|
||||
* @throws ExpectationException
|
||||
*/
|
||||
protected function get_step_options($options, $step) {
|
||||
// Nothing to fill if no options are provided.
|
||||
if (!$options) {
|
||||
return;
|
||||
}
|
||||
|
||||
$pageoptions = clone $options;
|
||||
|
||||
$rows = $options->getRows();
|
||||
$newrows = array();
|
||||
foreach ($rows as $k => $data) {
|
||||
if (count($data) !== 3) {
|
||||
// Not enough information to guess the page.
|
||||
throw new ExpectationException("The backup/restore step must be specified for all backup options");
|
||||
} else if ($data[0] == $step) {
|
||||
unset($data[0]);
|
||||
$newrows[] = $data;
|
||||
}
|
||||
}
|
||||
$pageoptions->setRows($newrows);
|
||||
return $pageoptions;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Waits until the DOM and the page Javascript code is ready.
|
||||
*
|
||||
|
@ -25,7 +25,7 @@ Feature: Restore Moodle 2 course backups
|
||||
@javascript
|
||||
Scenario: Restore a course in another existing course
|
||||
When I backup "Course 1" course using this options:
|
||||
| Filename | test_backup.mbz |
|
||||
| Confirmation | Filename | test_backup.mbz |
|
||||
And I restore "test_backup.mbz" backup into "Course 2" course using this options:
|
||||
Then I should see "Course 2"
|
||||
And I should see "Community finder" in the "Community finder" "block"
|
||||
@ -34,9 +34,9 @@ Feature: Restore Moodle 2 course backups
|
||||
@javascript
|
||||
Scenario: Restore a course in a new course
|
||||
When I backup "Course 1" course using this options:
|
||||
| Filename | test_backup.mbz |
|
||||
| Confirmation | Filename | test_backup.mbz |
|
||||
And I restore "test_backup.mbz" backup into a new course using this options:
|
||||
| Course name | Course 1 restored in a new course |
|
||||
| Schema | Course name | Course 1 restored in a new course |
|
||||
Then I should see "Course 1 restored in a new course"
|
||||
And I should see "Community finder" in the "Community finder" "block"
|
||||
And I should see "Test forum name"
|
||||
@ -50,12 +50,12 @@ Feature: Restore Moodle 2 course backups
|
||||
@javascript
|
||||
Scenario: Restore a backup into the same course
|
||||
When I backup "Course 3" course using this options:
|
||||
| Filename | test_backup.mbz |
|
||||
| Confirmation | Filename | test_backup.mbz |
|
||||
And I restore "test_backup.mbz" backup into "Course 2" course using this options:
|
||||
| setting_section_section_3_included | 0 |
|
||||
| setting_section_section_3_userinfo | 0 |
|
||||
| setting_section_section_5_included | 0 |
|
||||
| setting_section_section_5_userinfo | 0 |
|
||||
| Schema | setting_section_section_3_included | 0 |
|
||||
| Schema | setting_section_section_3_userinfo | 0 |
|
||||
| Schema | setting_section_section_5_included | 0 |
|
||||
| Schema | setting_section_section_5_userinfo | 0 |
|
||||
Then I should see "Course 2"
|
||||
And I should see "Test assign name"
|
||||
And I should not see "Test database name"
|
||||
@ -63,15 +63,15 @@ Feature: Restore Moodle 2 course backups
|
||||
@javascript
|
||||
Scenario: Restore a backup into the same course removing it's contents before that
|
||||
When I backup "Course 1" course using this options:
|
||||
| Filename | test_backup.mbz |
|
||||
| Confirmation | Filename | test_backup.mbz |
|
||||
And I follow "Course 1"
|
||||
And I add a "Forum" to section "1" and I fill the form with:
|
||||
| Forum name | Test forum post backup name |
|
||||
| Description | Test forum post backup description |
|
||||
And I follow "Restore"
|
||||
And I merge "test_backup.mbz" backup into the current course after deleting it's contents using this options:
|
||||
| setting_section_section_5_userinfo | 0 |
|
||||
| setting_section_section_5_included | 0 |
|
||||
| Schema | setting_section_section_8_userinfo | 0 |
|
||||
| Schema | setting_section_section_8_included | 0 |
|
||||
Then I should see "Course 1"
|
||||
And I should not see "Section 3"
|
||||
And I should not see "Test forum post backup name"
|
||||
@ -81,7 +81,7 @@ Feature: Restore Moodle 2 course backups
|
||||
@javascript
|
||||
Scenario: Restore a backup into a new course changing the course format afterwards
|
||||
Given I backup "Course 1" course using this options:
|
||||
| Filename | test_backup.mbz |
|
||||
| Confirmation | Filename | test_backup.mbz |
|
||||
When I restore "test_backup.mbz" backup into a new course using this options:
|
||||
Then I should see "Topic 1"
|
||||
And I should see "Test forum name"
|
||||
@ -117,9 +117,9 @@ Feature: Restore Moodle 2 course backups
|
||||
And I hide section "3"
|
||||
And I hide section "7"
|
||||
When I backup "Course 1" course using this options:
|
||||
| Filename | test_backup.mbz |
|
||||
| Confirmation | Filename | test_backup.mbz |
|
||||
And I restore "test_backup.mbz" backup into "Course 2" course using this options:
|
||||
| Overwrite course configuration | Yes |
|
||||
| Schema | Overwrite course configuration | Yes |
|
||||
And I click on "Edit settings" "link" in the "Administration" "block"
|
||||
And I expand all fieldsets
|
||||
Then the field "id_format" matches value "Topics format"
|
||||
|
Loading…
x
Reference in New Issue
Block a user