MDL-38863 behat: Role assign generator
[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"
4aad6f02
EL
33 When I go to the courses management page
34 And I follow "Cat 1"
35 Then I should see "Cat 2"
36 And I should see "Cat 3"
37 When I follow "Cat 3"
38 Then I should see "Course 1"
39 And I should see "Course 2"
40 When I select "Cat 2" from "Course categories:"
41 Then I should see "No courses in this category"
42 When I select "Miscellaneous" from "Course categories:"
43 Then 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
bedc20aa
DM
110 @javascript
111 Scenario: Add relations between users and groups
112 Given the following "users" exists:
113 | username | firstname | lastname | email |
114 | student1 | Student | 1 | student1@asd.com |
115 | student2 | Student | 2 | student2@asd.com |
116 And the following "courses" exists:
117 | fullname | shortname |
118 | Course 1 | C1 |
119 And the following "groups" exists:
120 | name | course | idnumber |
121 | Group 1 | C1 | G1 |
122 | Group 2 | C1 | G2 |
123 And the following "groupings" exists:
124 | name | course | idnumber |
125 | Grouping 1 | C1 | GG1 |
126 And the following "course enrolments" exists:
127 | user | course | role |
128 | student1 | C1 | student |
129 | student2 | C1 | student |
130 And the following "group members" exists:
131 | user | group |
132 | student1 | G1 |
133 | student2 | G2 |
134 And the following "grouping groups" exists:
135 | grouping | group |
136 | GG1 | G1 |
137 When I log in as "admin"
138 And I follow "Course 1"
139 And I expand "Users" node
140 And I follow "Groups"
141 Then the "groups" select box should contain "Group 1 (1)"
142 And the "groups" select box should contain "Group 2 (1)"
143 And I select "Group 1 (1)" from "groups"
cd65dc32 144 And I wait "5" seconds
bedc20aa
DM
145 And the "members" select box should contain "Student 1"
146 And I select "Group 2 (1)" from "groups"
cd65dc32 147 And I wait "5" seconds
bedc20aa 148 And the "members" select box should contain "Student 2"