‪TYPO3CMS  11.5
ListUserCest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Codeception\Scenario;
22 
27 {
31  public function ‪_before(‪ApplicationTester $I): void
32  {
33  $I->useExistingSession('admin');
34 
35  $I->see('Backend Users');
36  $I->click('Backend Users');
37 
38  $I->switchToContentFrame();
39  $I->wait(1);
40  $I->waitForElementVisible('.t3-js-jumpMenuBox');
41  $I->selectOption('.t3-js-jumpMenuBox', 'Backend users');
42  $I->wait(1);
43  }
44 
48  public function ‪showsHeadingAndListsBackendUsers(‪ApplicationTester $I, Scenario $scenario): void
49  {
50  $I->see('Backend User Listing');
51 
52  $I->wantTo('See the table of users');
53  $I->waitForElementVisible('#typo3-backend-user-list');
54  $I->click('button[value="reset-filters"]');
55  $I->waitForElementVisible('#typo3-backend-user-list');
56 
57  $isComposerMode = str_contains($scenario->current('env'), 'composer');
58  // We expect exactly four Backend Users to have been created by the fixtures
59  $expectedUsers = 4;
60  if ($isComposerMode) {
61  // User _cli_ will additionally be available in composer mode, created
62  // by execution of `vendor/bin/typo3` CLI in setup script.
63  $expectedUsers++;
64  }
65  $this->‪checkCountOfUsers($I, $expectedUsers);
66  }
67 
71  public function ‪filterUsersByUsername(‪ApplicationTester $I, Scenario $scenario): void
72  {
73  $I->wantTo('See the table of users');
74  $I->waitForElementVisible('#typo3-backend-user-list');
75  $I->click('button[value="reset-filters"]');
76  $I->waitForElementVisible('#typo3-backend-user-list');
77  $isComposerMode = str_contains($scenario->current('env'), 'composer');
78  $expectedUsers = 4;
79  if ($isComposerMode) {
80  $expectedUsers++;
81  }
82  $I->canSeeNumberOfElements('#typo3-backend-user-list tbody tr', $expectedUsers);
83 
84  $I->wantTo('Filter the list of user by valid username admin');
85  $I->fillField('#tx_Beuser_username', 'admin');
86  $I->click('Filter');
87  $I->waitForElementNotVisible('div#nprogess');
88  $I->waitForElementVisible('#typo3-backend-user-list');
89 
90  // We expect exact one fitting Backend User created from the Fixtures
91  $this->‪checkCountOfUsers($I, 1);
92 
93  $I->wantTo('Filter the list of user by valid username administrator');
94  $I->fillField('#tx_Beuser_username', 'administrator');
95  $I->click('Filter');
96  $I->waitForElementNotVisible('div#nprogess');
97  $I->waitForElementVisible('#typo3-backend-user-list');
98 
99  // We expect exact no fitting Backend User created from the Fixtures
100  $this->‪checkCountOfUsers($I, 0);
101  }
102 
106  public function ‪filterUsersByAdmin(‪ApplicationTester $I, Scenario $scenario): void
107  {
108  $I->wantTo('See the table of users');
109  $I->waitForElementVisible('#typo3-backend-user-list');
110  $I->click('button[value="reset-filters"]');
111  $I->waitForElementVisible('#typo3-backend-user-list');
112  $isComposerMode = str_contains($scenario->current('env'), 'composer');
113  $expectedUsers = 4;
114  if ($isComposerMode) {
115  $expectedUsers++;
116  }
117  $I->canSeeNumberOfElements('#typo3-backend-user-list tbody tr', $expectedUsers);
118 
119  $I->wantToTest('Filter BackendUser and see only admins');
120  $I->selectOption('#tx_Beuser_usertype', 'Admin only');
121  $I->click('Filter');
122  $I->waitForElementNotVisible('div#nprogess');
123  $I->waitForElementVisible('#typo3-backend-user-list');
124 
125  // We expect exact two (composer-mode: three) fitting Backend Users created from the Fixtures
126  $this->‪checkCountOfUsers($I, 2 + ($isComposerMode ? 1 : 0));
127 
128  $I->wantToTest('Filter BackendUser and see normal users');
129  $I->selectOption('#tx_Beuser_usertype', 'Normal users only');
130  $I->click('Filter');
131  $I->waitForElementNotVisible('div#nprogess');
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 
141  public function ‪filterUsersByStatus(‪ApplicationTester $I, Scenario $scenario): void
142  {
143  $I->wantTo('See the table of users');
144  $I->waitForElementVisible('#typo3-backend-user-list');
145  $I->click('button[value="reset-filters"]');
146  $I->waitForElementVisible('#typo3-backend-user-list');
147  $isComposerMode = str_contains($scenario->current('env'), 'composer');
148  $expectedUsers = 4;
149  if ($isComposerMode) {
150  $expectedUsers++;
151  }
152  $I->canSeeNumberOfElements('#typo3-backend-user-list tbody tr', $expectedUsers);
153 
154  $I->wantToTest('Filter BackendUser and see only active users');
155  $I->selectOption('#tx_Beuser_status', 'Active only');
156  $I->click('Filter');
157  $I->waitForElementNotVisible('div#nprogess');
158  $I->waitForElementVisible('#typo3-backend-user-list');
159 
160  // We expect exact two (composer-mode three) fitting Backend Users created from the Fixtures
161  $this->‪checkCountOfUsers($I, 2 + ($isComposerMode ? 1 : 0));
162 
163  $I->wantToTest('Filter BackendUser and see only inactive users');
164  $I->selectOption('#tx_Beuser_status', 'Inactive only');
165  $I->click('Filter');
166  $I->waitForElementNotVisible('div#nprogess');
167  $I->waitForElementVisible('#typo3-backend-user-list');
168 
169  // We expect exact two fitting Backend Users created from the Fixtures
170  $this->‪checkCountOfUsers($I, 2);
171  }
172 
176  public function ‪filterUsersByLogin(‪ApplicationTester $I, Scenario $scenario): void
177  {
178  $I->wantTo('See the table of users');
179  $I->waitForElementVisible('#typo3-backend-user-list');
180  $I->click('button[value="reset-filters"]');
181  $I->waitForElementVisible('#typo3-backend-user-list');
182  $isComposerMode = str_contains($scenario->current('env'), 'composer');
183  $expectedUsers = 4;
184  if ($isComposerMode) {
185  $expectedUsers++;
186  }
187  $I->canSeeNumberOfElements('#typo3-backend-user-list tbody tr', $expectedUsers);
188 
189  $I->wantToTest('Filter BackendUser and see only users logged in before');
190  $I->selectOption('#tx_Beuser_logins', 'Logged in before');
191  $I->click('Filter');
192  $I->waitForElementNotVisible('div#nprogess');
193  $I->waitForElementVisible('#typo3-backend-user-list');
194 
195  // We expect exact two fitting Backend Users created from the Fixtures
196  $this->‪checkCountOfUsers($I, 2);
197 
198  $I->wantToTest('Filter BackendUser and see only users never logged in before');
199  $I->selectOption('#tx_Beuser_logins', 'Never logged in');
200  $I->click('Filter');
201  $I->waitForElementNotVisible('div#nprogess');
202  $I->waitForElementVisible('#typo3-backend-user-list');
203 
204  // We expect exact two (composer-mode three) fitting Backend Users created from the Fixtures
205  $this->‪checkCountOfUsers($I, 2 + ($isComposerMode ? 1 : 0));
206  }
207 
211  public function ‪filterUsersByUserGroup(‪ApplicationTester $I, Scenario $scenario): void
212  {
213  $I->wantTo('See the table of users');
214  $I->waitForElementVisible('#typo3-backend-user-list');
215  $I->click('button[value="reset-filters"]');
216  $I->waitForElementVisible('#typo3-backend-user-list');
217  $isComposerMode = str_contains($scenario->current('env'), 'composer');
218  $expectedUsers = 4;
219  if ($isComposerMode) {
220  $expectedUsers++;
221  }
222  $I->canSeeNumberOfElements('#typo3-backend-user-list tbody tr', $expectedUsers);
223 
224  // We expect exact one Backend Users created from the Fixtures has the usergroup named 'editor-group'
225  $I->wantToTest('Filter BackendUser and see only users with given usergroup');
226  $I->selectOption('#tx_beuser_backendUserGroup', 'editor-group');
227  $I->click('Filter');
228  $I->waitForElementNotVisible('div#nprogess');
229  $I->waitForElementVisible('#typo3-backend-user-list');
230 
231  // We expect exact one fitting Backend User created from the Fixtures
232  $this->‪checkCountOfUsers($I, 1);
233  }
234 
239  public function ‪canEditUsersFromIndexListView(‪ApplicationTester $I, Scenario $scenario): void
240  {
241  $I->canSee('Backend User Listing', 'h1');
242  $I->waitForElementVisible('#typo3-backend-user-list');
243  $I->click('button[value="reset-filters"]');
244  $I->waitForElementVisible('#typo3-backend-user-list');
245  $username = 'admin';
246  $adminRow = '//*[@id="typo3-backend-user-list"]//tr[contains(td[2]/a[1]/b[1], "' . $username . '")]';
247 
248  $I->amGoingTo('test the edit button');
249  $I->click($adminRow . '//div[@role="group"]/a[@title="Edit"]');
250  $this->‪openAndCloseTheEditForm($I, $username);
251 
252  $I->amGoingTo('test the edit link on username');
253  $I->click($adminRow . '//td[@class="col-title"]/a[1]');
254  $this->‪openAndCloseTheEditForm($I, $username);
255 
256  $isComposerMode = str_contains($scenario->current('env'), 'composer');
257  // No "real name" in composer-mode since typo3-console doesn't allow
258  // to define a real-name, but forces admin-user creation.
259  if (!$isComposerMode) {
260  $I->amGoingTo('test the edit link on real name');
261  $I->click($adminRow . '//td[@class="col-title"]/a[2]');
262  $this->‪openAndCloseTheEditForm($I, $username);
263  }
264  }
265 
270  private function ‪checkCountOfUsers(‪ApplicationTester $I, int $countOfUsers): void
271  {
272  $I->canSeeNumberOfElements('#typo3-backend-user-list tbody tr', $countOfUsers);
273  $I->wantToTest('If a number of users is shown in the footer row');
274  $I->canSeeNumberOfElements('#typo3-backend-user-list tfoot tr', 1);
275  $I->see($countOfUsers . ' Users', '#typo3-backend-user-list tfoot tr');
276  }
277 
282  private function ‪openAndCloseTheEditForm(‪ApplicationTester $I, string $username): void
283  {
284  $I->waitForElementNotVisible('#t3js-ui-block');
285  $I->canSee('Edit Backend user "' . $username . '" on root level');
286 
287  $I->click('div.module-docheader .btn.t3js-editform-close');
288  $I->waitForElementVisible('table.table-striped');
289  $I->canSee('Backend User Listing', 'h1');
290  }
291 }
‪TYPO3\CMS\Core\Tests\Acceptance\Application\BackendUser\ListUserCest\filterUsersByUserGroup
‪filterUsersByUserGroup(ApplicationTester $I, Scenario $scenario)
Definition: ListUserCest.php:211
‪TYPO3\CMS\Core\Tests\Acceptance\Support\ApplicationTester
Definition: ApplicationTester.php:27
‪TYPO3\CMS\Core\Tests\Acceptance\Application\BackendUser\ListUserCest\canEditUsersFromIndexListView
‪canEditUsersFromIndexListView(ApplicationTester $I, Scenario $scenario)
Definition: ListUserCest.php:239
‪TYPO3\CMS\Core\Tests\Acceptance\Application\BackendUser\ListUserCest\showsHeadingAndListsBackendUsers
‪showsHeadingAndListsBackendUsers(ApplicationTester $I, Scenario $scenario)
Definition: ListUserCest.php:48
‪TYPO3\CMS\Core\Tests\Acceptance\Application\BackendUser\ListUserCest\filterUsersByAdmin
‪filterUsersByAdmin(ApplicationTester $I, Scenario $scenario)
Definition: ListUserCest.php:106
‪TYPO3\CMS\Core\Tests\Acceptance\Application\BackendUser\ListUserCest
Definition: ListUserCest.php:27
‪TYPO3\CMS\Core\Tests\Acceptance\Application\BackendUser\ListUserCest\filterUsersByStatus
‪filterUsersByStatus(ApplicationTester $I, Scenario $scenario)
Definition: ListUserCest.php:141
‪TYPO3\CMS\Core\Tests\Acceptance\Application\BackendUser\ListUserCest\openAndCloseTheEditForm
‪openAndCloseTheEditForm(ApplicationTester $I, string $username)
Definition: ListUserCest.php:282
‪TYPO3\CMS\Core\Tests\Acceptance\Application\BackendUser
Definition: CompareUserCest.php:18
‪TYPO3\CMS\Core\Tests\Acceptance\Application\BackendUser\ListUserCest\filterUsersByUsername
‪filterUsersByUsername(ApplicationTester $I, Scenario $scenario)
Definition: ListUserCest.php:71
‪TYPO3\CMS\Core\Tests\Acceptance\Application\BackendUser\ListUserCest\_before
‪_before(ApplicationTester $I)
Definition: ListUserCest.php:31
‪TYPO3\CMS\Core\Tests\Acceptance\Application\BackendUser\ListUserCest\filterUsersByLogin
‪filterUsersByLogin(ApplicationTester $I, Scenario $scenario)
Definition: ListUserCest.php:176
‪TYPO3\CMS\Core\Tests\Acceptance\Application\BackendUser\ListUserCest\checkCountOfUsers
‪checkCountOfUsers(ApplicationTester $I, int $countOfUsers)
Definition: ListUserCest.php:270