MDL-40673 behat: Data generator for permission overrides
[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"
38976081
DM
40 And I select "Cat 1 / Cat 2" from "Course categories:"
41 And I should see "No courses in this category"
42 And I select "Miscellaneous" from "Course categories:"
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
68 Scenario: Add course enrolments
69 Given the following "users" exists:
70 | username | firstname | lastname | email |
71 | student1 | Student | 1 | student1@asd.com |
72 And the following "courses" exists:
73 | fullname | shortname | format |
74 | Course 1 | C1 | topics |
75 And the following "course enrolments" exists:
76 | user | course | role |
77 | student1 | C1 | student |
78 When I log in as "student1"
79 And I follow "Course 1"
80 Then I should see "Topic 1"
81
72ddc05f
DM
82 Scenario: Add role assigns
83 Given the following "users" exists:
84 | username | firstname | lastname | email |
85 | user1 | User | 1 | user1@moodlemoodle.com |
86 | user2 | User | 2 | user2@moodlemoodle.com |
87 | user3 | User | 3 | user3@moodlemoodle.com |
88 And the following "categories" exists:
89 | name | category | idnumber |
90 | Cat 1 | 0 | CAT1 |
91 And the following "courses" exists:
92 | fullname | shortname | category |
93 | Course 1 | C1 | CAT1 |
94 And the following "role assigns" exists:
95 | user | role | contextlevel | reference |
96 | user1 | manager | System | |
97 | user2 | editingteacher | Category | CAT1 |
98 | user3 | editingteacher | Course | C1 |
99 When I log in as "user1"
100 Then I should see "Front page settings"
101 And I log out
102 And I log in as "user2"
103 And I follow "Course 1"
104 And I should see "Turn editing on"
105 And I log out
106 And I log in as "user3"
107 And I follow "Course 1"
108 And I should see "Turn editing on"
109
a0902967
DM
110 Scenario: Add modules
111 Given the following "courses" exists:
112 | fullname | shortname |
113 | Course 1 | C1 |
114 And the following "activities" exists:
115 | activity | name | intro | course | idnumber |
116 | assign | Test assignment name | Test assignment description | C1 | assign1 |
117 | data | Test database name | Test database description | C1 | data1 |
118 When I log in as "admin"
119 And I follow "Course 1"
120 Then I should see "Test assignment name"
121 And I should see "Test database name"
122 And I follow "Test assignment name"
123 And I should see "Test assignment description"
124
bedc20aa
DM
125 @javascript
126 Scenario: Add relations between users and groups
127 Given the following "users" exists:
128 | username | firstname | lastname | email |
129 | student1 | Student | 1 | student1@asd.com |
130 | student2 | Student | 2 | student2@asd.com |
131 And the following "courses" exists:
132 | fullname | shortname |
133 | Course 1 | C1 |
134 And the following "groups" exists:
135 | name | course | idnumber |
136 | Group 1 | C1 | G1 |
137 | Group 2 | C1 | G2 |
138 And the following "groupings" exists:
139 | name | course | idnumber |
140 | Grouping 1 | C1 | GG1 |
141 And the following "course enrolments" exists:
142 | user | course | role |
143 | student1 | C1 | student |
144 | student2 | C1 | student |
145 And the following "group members" exists:
146 | user | group |
147 | student1 | G1 |
148 | student2 | G2 |
149 And the following "grouping groups" exists:
150 | grouping | group |
151 | GG1 | G1 |
152 When I log in as "admin"
153 And I follow "Course 1"
154 And I expand "Users" node
155 And I follow "Groups"
156 Then the "groups" select box should contain "Group 1 (1)"
157 And the "groups" select box should contain "Group 2 (1)"
158 And I select "Group 1 (1)" from "groups"
cd65dc32 159 And I wait "5" seconds
bedc20aa
DM
160 And the "members" select box should contain "Student 1"
161 And I select "Group 2 (1)" from "groups"
cd65dc32 162 And I wait "5" seconds
bedc20aa 163 And the "members" select box should contain "Student 2"