From 7519d366ef441b4dad415ce13ea9a3a11a0e161e Mon Sep 17 00:00:00 2001 From: Rex Lorenzo Date: Thu, 19 Mar 2015 16:38:22 -0700 Subject: [PATCH] MDL-49595 backup: Behat tests for importing groups/groupings * Also fixed a missing required parameter for an Exception and some coding standards issues. --- backup/util/ui/tests/behat/behat_backup.php | 9 ++-- .../util/ui/tests/behat/import_groups.feature | 53 +++++++++++++++++++ 2 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 backup/util/ui/tests/behat/import_groups.feature diff --git a/backup/util/ui/tests/behat/behat_backup.php b/backup/util/ui/tests/behat/behat_backup.php index 4a31e06ff19a5..497283761a591 100644 --- a/backup/util/ui/tests/behat/behat_backup.php +++ b/backup/util/ui/tests/behat/behat_backup.php @@ -163,7 +163,8 @@ public function i_import_course_into_course($fromcourse, $tocourse, $options = f $this->wait(); // Select the course. - $exception = new ExpectationException('"' . $fromcourse . '" course not found in the list of courses to import from', $this->getSession()); + $exception = new ExpectationException('"' . $fromcourse . '" course not found in the list of courses to import from', + $this->getSession()); // The argument should be converted to an xpath literal. $fromcourse = $this->getSession()->getSelectorsHandler()->xpathLiteral($fromcourse); @@ -332,7 +333,8 @@ public function i_merge_backup_into_current_course_deleting_its_contents($backup protected function select_backup($backupfilename) { // Using xpath as there are other restore links before this one. - $exception = new ExpectationException('The "' . $backupfilename . '" backup file can not be found in this page', $this->getSession()); + $exception = new ExpectationException('The "' . $backupfilename . '" backup file can not be found in this page', + $this->getSession()); // The argument should be converted to an xpath literal. $backupfilename = $this->getSession()->getSelectorsHandler()->xpathLiteral($backupfilename); @@ -424,7 +426,8 @@ protected function get_step_options($options, $step) { 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"); + throw new ExpectationException("The backup/restore step must be specified for all backup options", + $this->getSession()); } else if ($data[0] == $step) { unset($data[0]); $newrows[] = $data; diff --git a/backup/util/ui/tests/behat/import_groups.feature b/backup/util/ui/tests/behat/import_groups.feature new file mode 100644 index 0000000000000..82b0b73a51d6e --- /dev/null +++ b/backup/util/ui/tests/behat/import_groups.feature @@ -0,0 +1,53 @@ +@core @core_backup +Feature: Option to include groups and groupings when importing a course to another course + In order to import a course to another course with groups and groupings + As a teacher + I need an option to include groups and groupings when importing a course to another course + + Background: + Given the following "courses" exist: + | fullname | shortname | + | Course 1 | C1 | + | Course 2 | C2 | + And the following "users" exist: + | username | firstname | lastname | email | + | teacher1 | Teacher | 1 | teacher1@asd.com | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + | teacher1 | C2 | editingteacher | + And the following "groups" exist: + | name | description | course | idnumber | + | Group 1 | Group description | C1 | GROUP1 | + | Group 2 | Group description | C1 | GROUP2 | + And the following "groupings" exist: + | name | course | idnumber | + | Grouping 1 | C1 | GROUPING1 | + | Grouping 2 | C1 | GROUPING2 | + And I log in as "teacher1" + And I follow "Course 1" + And I turn editing mode on + + @javascript + Scenario: Include groups and groupings when importing a course to another course + When I import "Course 1" course into "Course 2" course using this options: + | Initial | Include groups and groupings | 1 | + And I expand "Users" node + And I follow "Groups" + Then I should see "Group 1" + And I should see "Group 2" + And I follow "Groupings" + And I should see "Grouping 1" + And I should see "Grouping 2" + + @javascript + Scenario: Do not include groups and groupings when importing a course to another course + When I import "Course 1" course into "Course 2" course using this options: + | Initial | Include groups and groupings | 0 | + And I expand "Users" node + And I follow "Groups" + Then I should not see "Group 1" + And I should not see "Group 2" + And I follow "Groupings" + And I should not see "Grouping 1" + And I should not see "Grouping 2" \ No newline at end of file