bef864d12b0f9485634f11e233e0a407e7592e20
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Acceptance / Backend / BackendUser / ListUserCest.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\BackendUser;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Core\Tests\Acceptance\Step\Backend\Admin;
18
19 /**
20 * List User tests
21 */
22 class ListUserCest
23 {
24 /**
25 * @param Admin $I
26 * @return void
27 */
28 public function _before(Admin $I)
29 {
30 $I->useExistingSession();
31
32 $I->see('Backend users');
33 $I->click('Backend users');
34
35 // switch to content iframe
36 $I->switchToIFrame('contentIframe');
37 }
38
39 /**
40 * @param Admin $I
41 * @return void
42 */
43 public function showsHeadingAndListsBackendUsers(Admin $I)
44 {
45 $I->see('Backend User Listing');
46
47 $I->wantTo('See the table of users');
48 $I->waitForElementVisible('#typo3-backend-user-list');
49
50 // We expect exact four Backend Users created from the Fixtures
51 $this->checkCountOfUsers($I, 4);
52 }
53
54 /**
55 * @param Admin $I
56 * @return void
57 */
58 public function filterUsersByUsername(Admin $I)
59 {
60 $I->wantTo('See the table of users');
61 $I->waitForElementVisible('#typo3-backend-user-list');
62 // We expect exact four Backend Users created from the Fixtures
63 $I->canSeeNumberOfElements('#typo3-backend-user-list tbody tr', 4);
64
65 $I->wantTo('Filter the list of user by valid username admin');
66 $I->fillField('#tx_Beuser_username', 'admin');
67 $I->click('Filter');
68 $I->waitForElementVisible('#typo3-backend-user-list');
69
70 // We expect exact one fitting Backend User created from the Fixtures
71 $this->checkCountOfUsers($I, 1);
72
73 $I->wantTo('Filter the list of user by valid username administrator');
74 $I->fillField('#tx_Beuser_username', 'administrator');
75 $I->click('Filter');
76 $I->waitForElementVisible('#typo3-backend-user-list');
77
78 // We expect exact no fitting Backend User created from the Fixtures
79 $this->checkCountOfUsers($I, 0);
80 }
81
82 /**
83 * @param Admin $I
84 * @return void
85 */
86 public function filterUsersByAdmin(Admin $I)
87 {
88 $I->wantTo('See the table of users');
89 $I->waitForElementVisible('#typo3-backend-user-list');
90 // We expect exact four Backend Users created from the Fixtures
91 $I->canSeeNumberOfElements('#typo3-backend-user-list tbody tr', 4);
92
93 $I->wantToTest('Filter BackendUser and see only admins');
94 $I->selectOption('#tx_Beuser_usertype', 'Admin only');
95 $I->click('Filter');
96 $I->waitForElementVisible('#typo3-backend-user-list');
97
98 // We expect exact two fitting Backend Users created from the Fixtures
99 $this->checkCountOfUsers($I, 2);
100
101 $I->wantToTest('Filter BackendUser and see normal users');
102 $I->selectOption('#tx_Beuser_usertype', 'Normal users only');
103 $I->click('Filter');
104 $I->waitForElementVisible('#typo3-backend-user-list');
105
106 // We expect exact two fitting Backend Users created from the Fixtures
107 $this->checkCountOfUsers($I, 2);
108 }
109
110 /**
111 * @param Admin $I
112 * @return void
113 */
114 public function filterUsersByStatus(Admin $I)
115 {
116 $I->wantTo('See the table of users');
117 $I->waitForElementVisible('#typo3-backend-user-list');
118 // We expect exact four Backend Users created from the Fixtures
119 $I->canSeeNumberOfElements('#typo3-backend-user-list tbody tr', 4);
120
121 $I->wantToTest('Filter BackendUser and see only active users');
122 $I->selectOption('#tx_Beuser_status', 'Active only');
123 $I->click('Filter');
124 $I->waitForElementVisible('#typo3-backend-user-list');
125
126 // We expect exact two fitting Backend Users created from the Fixtures
127 $this->checkCountOfUsers($I, 2);
128
129 $I->wantToTest('Filter BackendUser and see only inactive users');
130 $I->selectOption('#tx_Beuser_status', 'Inactive only');
131 $I->click('Filter');
132 $I->waitForElementVisible('#typo3-backend-user-list');
133
134 // We expect exact two fitting Backend Users created from the Fixtures
135 $this->checkCountOfUsers($I, 2);
136 }
137
138 /**
139 * @param Admin $I
140 * @return void
141 */
142 public function filterUsersByLogin(Admin $I)
143 {
144 $I->wantTo('See the table of users');
145 $I->waitForElementVisible('#typo3-backend-user-list');
146 // We expect exact four Backend Users created from the Fixtures
147 $I->canSeeNumberOfElements('#typo3-backend-user-list tbody tr', 4);
148
149 $I->wantToTest('Filter BackendUser and see only users logged in before');
150 $I->selectOption('#tx_Beuser_logins', 'Logged in before');
151 $I->click('Filter');
152 $I->waitForElementVisible('#typo3-backend-user-list');
153
154 // We expect exact two fitting Backend Users created from the Fixtures
155 $this->checkCountOfUsers($I, 2);
156
157 $I->wantToTest('Filter BackendUser and see only users never logged in before');
158 $I->selectOption('#tx_Beuser_logins', 'Never logged in');
159 $I->click('Filter');
160 $I->waitForElementVisible('#typo3-backend-user-list');
161
162 // We expect exact two fitting Backend Users created from the Fixtures
163 $this->checkCountOfUsers($I, 2);
164 }
165
166 /**
167 * @param Admin $I
168 * @return void
169 */
170 public function filterUsersByUserGroup(Admin $I)
171 {
172 $I->wantTo('See the table of users');
173 $I->waitForElementVisible('#typo3-backend-user-list');
174 // We expect exact four Backend Users created from the Fixtures
175 $I->canSeeNumberOfElements('#typo3-backend-user-list tbody tr', 4);
176
177 // We expect exact one Backend Users created from the Fixtures has the usergroup named 'editor-group'
178 $I->wantToTest('Filter BackendUser and see only users with given usergroup');
179 $I->selectOption('#tx_beuser_backendUserGroup', 'editor-group');
180 $I->click('Filter');
181 $I->waitForElementVisible('#typo3-backend-user-list');
182
183 // We expect exact one fitting Backend User created from the Fixtures
184 $this->checkCountOfUsers($I, 1);
185 }
186
187 /**
188 * @param Admin $I
189 * @param int $countOfUsers
190 * @return void
191 */
192 protected function checkCountOfUsers(Admin $I, $countOfUsers)
193 {
194 $I->canSeeNumberOfElements('#typo3-backend-user-list tbody tr', $countOfUsers);
195 $I->wantToTest('If a number of users is shown in the footer row');
196 $I->canSeeNumberOfElements('#typo3-backend-user-list tfoot tr', 1);
197 $I->see($countOfUsers . ' Users', '#typo3-backend-user-list tfoot tr');
198 }
199 }