weekly release 2.7dev
[moodle.git] / admin / tool / behat / tests / behat / data_generators.feature
CommitLineData
550d842e 1@tool @tool_behat
bedc20aa
DM
2Feature: Set up contextual data for tests
3 In order to write tests quickly
5d7b6307 4 As a developer
bedc20aa
DM
5 I need to fill the database with fixtures
6
7 Scenario: Add a bunch of users
8 Given the following "users" exists:
9 | username | password | firstname | lastname |
10 | testuser | testuser | | |
11 | testuser2 | testuser2 | TestFirstname | TestLastname |
12 And I log in as "testuser"
13 And I log out
14 When I log in as "testuser2"
15 Then I should see "TestFirstname"
16
17 @javascript
18 Scenario: Add a bunch of courses and categories
19 Given the following "categories" exists:
20 | name | category | idnumber |
21 | Cat 1 | 0 | CAT1 |
22 | Cat 2 | CAT1 | CAT2 |
23 | Cat 3 | CAT1 | CAT3 |
24 And the following "courses" exists:
25 | fullname | shortname | category |
26 | Course 1 | COURSE1 | CAT3 |
27 | Course 2 | COURSE2 | CAT3 |
28 | Course 3 | COURSE3 | 0 |
29 When I log in as "admin"
30 Then I should see "Course 1"
31 And I should see "Course 2"
32 And I should see "Course 3"
38976081 33 And I go to the courses management page
4aad6f02 34 And I follow "Cat 1"
38976081 35 And I should see "Cat 2"
4aad6f02 36 And I should see "Cat 3"
38976081
DM
37 And I follow "Cat 3"
38 And I should see "Course 1"
4aad6f02 39 And I should see "Course 2"
5dc361e1 40 And I follow "Cat 2"
38976081 41 And I should see "No courses in this category"
5dc361e1 42 And I follow "Miscellaneous"
38976081 43 And I should see "Course 3"
bedc20aa
DM
44
45 @javascript
46 Scenario: Add a bunch of groups and groupings
47 Given the following "courses" exists:
48 | fullname | shortname |
49 | Course 1 | C1 |
50 And the following "groups" exists:
51 | name | course | idnumber |
52 | Group 1 | C1 | G1 |
53 | Group 2 | C1 | G2 |
54 And the following "groupings" exists:
55 | name | course | idnumber |
56 | Grouping 1 | C1 | GG1 |
57 | Grouping 2 | C1 | GG2 |
58 When I log in as "admin"
59 And I follow "Course 1"
60 And I expand "Users" node
61 And I follow "Groups"
62 Then I should see "Group 1"
63 And I should see "Group 2"
64 And I follow "Groupings"
65 And I should see "Grouping 1"
66 And I should see "Grouping 2"
67
118d53f9
DM
68 @javascript
69 Scenario: Role overrides
70 Given the following "users" exists:
71 | username | firstname | lastname | email |
72 | teacher1 | Teacher | 1 | teacher1@asd.com |
73 | student1 | Student | 1 | student1@asd.com |
74 And the following "categories" exists:
75 | name | category | idnumber |
76 | Cat 1 | 0 | CAT1 |
77 And the following "courses" exists:
78 | fullname | shortname |
79 | Course 1 | C1 |
80 And the following "course enrolments" exists:
81 | user | course | role |
82 | student1 | C1 | student |
83 | teacher1 | C1 | editingteacher |
84 And the following "permission overrides" exists:
85 | capability | permission | role | contextlevel | reference |
86 | mod/forum:editanypost | Allow | student | Course | C1 |
87 | mod/forum:replynews | Prevent | editingteacher | Course | C1 |
88 When I log in as "admin"
89 And I follow "Course 1"
90 And I expand "Users" node
91 And I follow "Permissions"
92 And I select "Student (1)" from "Advanced role override"
93 Then the "mod/forum:editanypost" field should match "1" value
94 And I press "Cancel"
95 And I select "Teacher (1)" from "Advanced role override"
96 And the "mod/forum:replynews" field should match "-1" value
97 And I press "Cancel"
98
bedc20aa
DM
99 Scenario: Add course enrolments
100 Given the following "users" exists:
101 | username | firstname | lastname | email |
102 | student1 | Student | 1 | student1@asd.com |
103 And the following "courses" exists:
104 | fullname | shortname | format |
105 | Course 1 | C1 | topics |
106 And the following "course enrolments" exists:
107 | user | course | role |
108 | student1 | C1 | student |
109 When I log in as "student1"
110 And I follow "Course 1"
111 Then I should see "Topic 1"
112
72ddc05f
DM
113 Scenario: Add role assigns
114 Given the following "users" exists:
115 | username | firstname | lastname | email |
116 | user1 | User | 1 | user1@moodlemoodle.com |
117 | user2 | User | 2 | user2@moodlemoodle.com |
118 | user3 | User | 3 | user3@moodlemoodle.com |
119 And the following "categories" exists:
120 | name | category | idnumber |
121 | Cat 1 | 0 | CAT1 |
122 And the following "courses" exists:
123 | fullname | shortname | category |
124 | Course 1 | C1 | CAT1 |
125 And the following "role assigns" exists:
126 | user | role | contextlevel | reference |
127 | user1 | manager | System | |
128 | user2 | editingteacher | Category | CAT1 |
129 | user3 | editingteacher | Course | C1 |
130 When I log in as "user1"
131 Then I should see "Front page settings"
132 And I log out
133 And I log in as "user2"
134 And I follow "Course 1"
135 And I should see "Turn editing on"
136 And I log out
137 And I log in as "user3"
138 And I follow "Course 1"
139 And I should see "Turn editing on"
140
a0902967
DM
141 Scenario: Add modules
142 Given the following "courses" exists:
143 | fullname | shortname |
144 | Course 1 | C1 |
145 And the following "activities" exists:
146 | activity | name | intro | course | idnumber |
147 | assign | Test assignment name | Test assignment description | C1 | assign1 |
148 | data | Test database name | Test database description | C1 | data1 |
149 When I log in as "admin"
150 And I follow "Course 1"
151 Then I should see "Test assignment name"
152 And I should see "Test database name"
153 And I follow "Test assignment name"
154 And I should see "Test assignment description"
155
bedc20aa
DM
156 @javascript
157 Scenario: Add relations between users and groups
158 Given the following "users" exists:
159 | username | firstname | lastname | email |
160 | student1 | Student | 1 | student1@asd.com |
161 | student2 | Student | 2 | student2@asd.com |
162 And the following "courses" exists:
163 | fullname | shortname |
164 | Course 1 | C1 |
165 And the following "groups" exists:
166 | name | course | idnumber |
167 | Group 1 | C1 | G1 |
168 | Group 2 | C1 | G2 |
169 And the following "groupings" exists:
170 | name | course | idnumber |
171 | Grouping 1 | C1 | GG1 |
172 And the following "course enrolments" exists:
173 | user | course | role |
174 | student1 | C1 | student |
175 | student2 | C1 | student |
176 And the following "group members" exists:
177 | user | group |
178 | student1 | G1 |
179 | student2 | G2 |
180 And the following "grouping groups" exists:
181 | grouping | group |
182 | GG1 | G1 |
183 When I log in as "admin"
184 And I follow "Course 1"
185 And I expand "Users" node
186 And I follow "Groups"
187 Then the "groups" select box should contain "Group 1 (1)"
188 And the "groups" select box should contain "Group 2 (1)"
189 And I select "Group 1 (1)" from "groups"
cd65dc32 190 And I wait "5" seconds
bedc20aa
DM
191 And the "members" select box should contain "Student 1"
192 And I select "Group 2 (1)" from "groups"
cd65dc32 193 And I wait "5" seconds
bedc20aa 194 And the "members" select box should contain "Student 2"