MDL-59602 enrol: Correct course name for restored course
[moodle.git] / enrol / meta / tests / behat / enrol_meta.feature
CommitLineData
6f326bd2 1@enrol @enrol_meta @javascript
9e37d365
MG
2Feature: Enrolments are synchronised with meta courses
3 In order to simplify enrolments in parent courses
4 As a teacher
5 I need to be able to set up meta enrolments
6
7 Background:
8 Given the following "users" exist:
9 | username | firstname | lastname | email |
10 | student1 | Student | 1 | student1@asd.com |
11 | student2 | Student | 2 | student2@asd.com |
12 | student3 | Student | 3 | student3@asd.com |
13 | student4 | Student | 4 | student4@asd.com |
14 And the following "courses" exist:
15 | fullname | shortname |
6f326bd2
DW
16 | Course 1 | C1C1 |
17 | Course 2 | C2C2 |
18 | Course 3 | C3C3 |
06aa5923 19 | Course 4 | C4C4 |
9e37d365
MG
20 And the following "groups" exist:
21 | name | course | idnumber |
6f326bd2
DW
22 | Groupcourse 1 | C3C3 | G1 |
23 | Groupcourse 2 | C3C3 | G2 |
9e37d365 24 And the following "course enrolments" exist:
06aa5923
JP
25 | user | course | role | status |
26 | student1 | C1C1 | student | 0 |
27 | student2 | C1C1 | student | 0 |
28 | student3 | C1C1 | student | 0 |
29 | student4 | C1C1 | student | 0 |
30 | student1 | C2C2 | student | 0 |
31 | student2 | C2C2 | student | 0 |
32 | student1 | C4C4 | student | 0 |
33 | student2 | C4C4 | student | 1 |
9e37d365
MG
34 And I log in as "admin"
35 And I navigate to "Manage enrol plugins" node in "Site administration > Plugins > Enrolments"
36 And I click on "Enable" "link" in the "Course meta link" "table_row"
e5287f9b 37 And I am on course index
9e37d365 38
9e37d365 39 Scenario: Add meta enrolment instance without groups
fdeeaff9 40 When I am on "Course 3" course homepage
9e37d365 41 And I add "Course meta link" enrolment method with:
6f326bd2 42 | Link course | C1C1 |
9e37d365
MG
43 And I navigate to "Enrolled users" node in "Course administration > Users"
44 Then I should see "Student 1"
45 And I should see "Student 4"
46 And I should not see "Groupcourse" in the "table.userenrolment" "css_element"
47
9e37d365 48 Scenario: Add meta enrolment instance with groups
fdeeaff9 49 When I am on "Course 3" course homepage
6f326bd2
DW
50 And I add "Course meta link" enrolment method with:
51 | Link course | C1C1 |
9e37d365 52 | Add to group | Groupcourse 1 |
fdeeaff9 53 And I am on "Course 3" course homepage
6f326bd2
DW
54 And I add "Course meta link" enrolment method with:
55 | Link course | C2C2 |
9e37d365 56 | Add to group | Groupcourse 2 |
9e37d365
MG
57 And I navigate to "Enrolled users" node in "Course administration > Users"
58 Then I should see "Groupcourse 1" in the "Student 1" "table_row"
59 And I should see "Groupcourse 1" in the "Student 2" "table_row"
60 And I should see "Groupcourse 1" in the "Student 3" "table_row"
61 And I should see "Groupcourse 1" in the "Student 4" "table_row"
62 And I should see "Groupcourse 2" in the "Student 1" "table_row"
63 And I should see "Groupcourse 2" in the "Student 2" "table_row"
64 And I should not see "Groupcourse 2" in the "Student 3" "table_row"
65 And I should not see "Groupcourse 2" in the "Student 4" "table_row"
66
e284e179 67 Scenario: Add meta enrolment instance with auto-created groups
fdeeaff9 68 When I am on "Course 3" course homepage
6f326bd2
DW
69 And I add "Course meta link" enrolment method with:
70 | Link course | C1C1 |
e284e179 71 | Add to group | Create new group |
e284e179
MG
72 And I navigate to "Enrolled users" node in "Course administration > Users"
73 Then I should see "Course 1 course" in the "Student 1" "table_row"
74 And I should see "Course 1 course" in the "Student 2" "table_row"
75 And I should see "Course 1 course" in the "Student 3" "table_row"
76 And I should see "Course 1 course" in the "Student 4" "table_row"
77 And I navigate to "Groups" node in "Course administration > Users"
78 And the "Groups" select box should contain "Course 1 course (4)"
79
9e37d365 80 Scenario: Backup and restore of meta enrolment instance
fdeeaff9 81 When I am on "Course 3" course homepage
6f326bd2
DW
82 And I add "Course meta link" enrolment method with:
83 | Link course | C1C1 |
9e37d365 84 | Add to group | Groupcourse 1 |
fdeeaff9 85 And I am on "Course 3" course homepage
6f326bd2
DW
86 And I add "Course meta link" enrolment method with:
87 | Link course | C2C2 |
9e37d365
MG
88 When I backup "Course 3" course using this options:
89 | Confirmation | Filename | test_backup.mbz |
90 And I click on "Restore" "link" in the "test_backup.mbz" "table_row"
91 And I press "Continue"
92 And I set the field "targetid" to "1"
93 And I click on "Continue" "button" in the ".bcs-new-course" "css_element"
94 And I press "Next"
3d4739ab 95 And I set the field "Course name" to "Course 5"
9e37d365
MG
96 And I press "Next"
97 And I press "Perform restore"
98 And I trigger cron
3d4739ab 99 And I am on "Course 5 copy 1" course homepage
9e37d365
MG
100 And I navigate to "Enrolment methods" node in "Course administration > Users"
101 Then I should see "Course meta link (Course 1)"
102 And I should see "Course meta link (Course 2)"
103 And I navigate to "Enrolled users" node in "Course administration > Users"
104 And I should see "Groupcourse 1" in the "Student 1" "table_row"
105 And I should see "Groupcourse 1" in the "Student 2" "table_row"
106 And I should see "Groupcourse 1" in the "Student 3" "table_row"
107 And I should see "Groupcourse 1" in the "Student 4" "table_row"
108 And I should see "Course 2" in the "Student 1" "table_row"
109 And I should not see "Course 2" in the "Student 3" "table_row"
06aa5923
JP
110
111 Scenario: Unenrol a user from the course participants page that was enrolled via course meta link.
112 Given I am on "Course 3" course homepage
113 And I add "Course meta link" enrolment method with:
114 | Link course | C4C4 |
115 And I navigate to course participants
116 # Suspended users can be unenrolled.
117 When I click on "//a[@data-action='unenrol']" "xpath_element" in the "student2" "table_row"
118 And I click on "Yes" "button"
119 Then I should not see "Student 2" in the "participants" "table"