MDL-64506 phpunit: Update unit tests to use classic
[moodle.git] / cohort / tests / behat / access_visible_cohorts.feature
CommitLineData
80f98467
MG
1@core @core_cohort @enrol_cohort
2Feature: Access visible and hidden cohorts
3 In order to enrol users from cohorts
4 As an manager or teacher
5 I need to be able to view the list of cohorts defined above the course
6
7 Background:
8 Given the following "categories" exist:
9 | name | category | idnumber |
10 | Cat 1 | 0 | CAT1 |
11 | Cat 2 | 0 | CAT2 |
12 And the following "cohorts" exist:
13 | name | idnumber | visible |
14 | System cohort | CV0 | 1 |
15 | System hidden cohort | CH0 | 0 |
16 | System empty cohort | CVE0 | 1 |
17 And the following "cohorts" exist:
18 | name | idnumber | contextlevel | reference | visible |
19 | Cohort in category 1 | CV1 | Category | CAT1 | 1 |
20 | Cohort in category 2 | CV2 | Category | CAT2 | 1 |
21 | Cohort hidden in category 1 | CH1 | Category | CAT1 | 0 |
22 | Cohort empty in category 1 | CVE1 | Category | CAT1 | 1 |
23 Given the following "users" exist:
24 | username | firstname | lastname | email |
0fe86bbd
RT
25 | user1 | First | User | first@example.com |
26 | user2 | Second | User | second@example.com |
27 | student | Sam | User | student@example.com |
28 | teacher | Terry | User | teacher@example.com |
80f98467
MG
29 And the following "cohort members" exist:
30 | user | cohort |
31 | student | CV0 |
32 | student | CV1 |
33 | student | CV2 |
34 | student | CH0 |
35 | student | CH1 |
36 And the following "role assigns" exist:
37 | user | role | contextlevel | reference |
38 | user1 | manager | System | |
39 | user2 | manager | Category | CAT1 |
40 And the following "courses" exist:
41 | fullname | shortname | category |
42 | Course 1 | C1 | CAT1 |
43 And the following "course enrolments" exist:
44 | user | course | role |
45 | teacher | C1 | editingteacher |
46
6b7d7404 47 @javascript
80f98467
MG
48 Scenario: Teacher can see visible cohorts defined in the above contexts
49 When I log in as "teacher"
fdeeaff9 50 And I am on "Course 1" course homepage
02fda279 51 And I navigate to "Users > Enrolment methods" in current page administration
a1d3a94b 52 And I select "Cohort sync" from the "Add method" singleselect
6b7d7404
DM
53 And I open the autocomplete suggestions list
54 Then "Cohort in category 1" "autocomplete_suggestions" should exist
55 And "System cohort" "autocomplete_suggestions" should exist
56 And "Cohort hidden in category 1" "autocomplete_suggestions" should not exist
57 And "System hidden cohort" "autocomplete_suggestions" should not exist
58 And "Cohort in category 2" "autocomplete_suggestions" should not exist
59 And "Cohort empty in category 1" "autocomplete_suggestions" should exist
60 And "System empty cohort" "autocomplete_suggestions" should exist
80f98467
MG
61 And I set the field "Cohort" to "System cohort"
62 And I press "Add method"
fdeeaff9 63 And I am on "Course 1" course homepage
02fda279 64 And I navigate to "Users > Enrolled users" in current page administration
0fe86bbd 65 And I should see "student@example.com"
fdeeaff9 66 And I am on "Course 1" course homepage
02fda279 67 And I navigate to "Users > Groups" in current page administration
80f98467
MG
68 And I press "Auto-create groups"
69 And the "Select members from cohort" select box should contain "Cohort in category 1"
70 And the "Select members from cohort" select box should contain "System cohort"
71 And the "Select members from cohort" select box should not contain "Cohort hidden in category 1"
72 And the "Select members from cohort" select box should not contain "System hidden cohort"
73 And the "Select members from cohort" select box should not contain "Cohort in category 2"
74 And the "Select members from cohort" select box should not contain "Cohort empty in category 1"
75 And the "Select members from cohort" select box should not contain "System empty cohort"
76
6b7d7404 77 @javascript
80f98467
MG
78 Scenario: System manager can see all cohorts defined in the above contexts
79 When I log in as "user1"
fdeeaff9 80 And I am on "Course 1" course homepage
02fda279 81 And I navigate to "Users > Enrolment methods" in current page administration
a1d3a94b 82 And I select "Cohort sync" from the "Add method" singleselect
6b7d7404
DM
83 And I open the autocomplete suggestions list
84 Then "Cohort in category 1" "autocomplete_suggestions" should exist
85 And "System cohort" "autocomplete_suggestions" should exist
86 And "Cohort hidden in category 1" "autocomplete_suggestions" should exist
87 And "System hidden cohort" "autocomplete_suggestions" should exist
88 And "Cohort in category 2" "autocomplete_suggestions" should not exist
89 And "Cohort empty in category 1" "autocomplete_suggestions" should exist
90 And "System empty cohort" "autocomplete_suggestions" should exist
80f98467
MG
91 And I set the field "Cohort" to "System cohort"
92 And I press "Add method"
02fda279
VDF
93 And I am on "Course 1" course homepage
94 And I navigate to "Users > Enrolled users" in current page administration
0fe86bbd 95 And I should see "student@example.com"
02fda279 96 And I navigate to "Users > Groups" in current page administration
80f98467
MG
97 And I press "Auto-create groups"
98 And the "Select members from cohort" select box should contain "Cohort in category 1"
99 And the "Select members from cohort" select box should contain "System cohort"
100 And the "Select members from cohort" select box should contain "Cohort hidden in category 1"
101 And the "Select members from cohort" select box should contain "System hidden cohort"
102 And the "Select members from cohort" select box should not contain "Cohort in category 2"
103 And the "Select members from cohort" select box should not contain "Cohort empty in category 1"
104 And the "Select members from cohort" select box should not contain "System empty cohort"
105
6b7d7404 106 @javascript
80f98467
MG
107 Scenario: Category manager can see all cohorts defined in his category and visible cohorts defined above
108 When I log in as "user2"
fdeeaff9 109 And I am on "Course 1" course homepage
02fda279 110 And I navigate to "Users > Enrolment methods" in current page administration
a1d3a94b 111 And I select "Cohort sync" from the "Add method" singleselect
6b7d7404
DM
112 And I open the autocomplete suggestions list
113 Then "Cohort in category 1" "autocomplete_suggestions" should exist
114 And "System cohort" "autocomplete_suggestions" should exist
115 And "Cohort hidden in category 1" "autocomplete_suggestions" should exist
116 And "System hidden cohort" "autocomplete_suggestions" should not exist
117 And "Cohort in category 2" "autocomplete_suggestions" should not exist
118 And "Cohort empty in category 1" "autocomplete_suggestions" should exist
119 And "System empty cohort" "autocomplete_suggestions" should exist
80f98467
MG
120 And I set the field "Cohort" to "System cohort"
121 And I press "Add method"
02fda279
VDF
122 And I am on "Course 1" course homepage
123 And I navigate to "Users > Enrolled users" in current page administration
0fe86bbd 124 And I should see "student@example.com"
02fda279 125 And I navigate to "Users > Groups" in current page administration
80f98467
MG
126 And I press "Auto-create groups"
127 And the "Select members from cohort" select box should contain "Cohort in category 1"
128 And the "Select members from cohort" select box should contain "System cohort"
129 And the "Select members from cohort" select box should contain "Cohort hidden in category 1"
130 And the "Select members from cohort" select box should not contain "System hidden cohort"
131 And the "Select members from cohort" select box should not contain "Cohort in category 2"
132 And the "Select members from cohort" select box should not contain "Cohort empty in category 1"
133 And the "Select members from cohort" select box should not contain "System empty cohort"