‪TYPO3CMS  ‪main
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 
26 final class ‪ListUserCest
27 {
28  public function ‪_before(‪ApplicationTester $I): void
29  {
30  $I->useExistingSession('admin');
31 
32  $I->see('Backend Users');
33  $I->click('Backend Users');
34 
35  $I->switchToContentFrame();
36  }
37 
38  public function ‪showsHeadingAndListsBackendUsers(‪ApplicationTester $I, Scenario $scenario): void
39  {
40  $I->see('Backend users');
41 
42  $I->wantTo('See the table of users');
43  $I->waitForElementVisible('#typo3-backend-user-list');
44  $I->click('button[value="reset-filters"]');
45  $I->waitForElementVisible('#typo3-backend-user-list');
46 
47  $isComposerMode = str_contains($scenario->current('env'), 'composer');
48  // We expect exactly four Backend Users to have been created by the fixtures
49  $expectedUsers = 4;
50  if ($isComposerMode) {
51  // User _cli_ will additionally be available in composer mode, created
52  // by execution of `vendor/bin/typo3` CLI in setup script.
53  $expectedUsers++;
54  }
55  $this->‪checkCountOfUsers($I, $expectedUsers);
56  }
57 
58  public function ‪filterUsersByUsername(‪ApplicationTester $I, Scenario $scenario): void
59  {
60  $I->wantTo('See the table of users');
61  $I->waitForElementVisible('#typo3-backend-user-list');
62  $I->click('button[value="reset-filters"]');
63  $I->waitForElementVisible('#typo3-backend-user-list');
64  $isComposerMode = str_contains($scenario->current('env'), 'composer');
65  $expectedUsers = 4;
66  if ($isComposerMode) {
67  $expectedUsers++;
68  }
69  $I->canSeeNumberOfElements('#typo3-backend-user-list tbody tr', $expectedUsers);
70 
71  $I->wantTo('Filter the list of user by valid username admin');
72  $I->fillField('#tx_Beuser_username', 'admin');
73  $I->click('Filter');
74  $I->waitForElementNotVisible('div#nprogess');
75  $I->waitForElementVisible('#typo3-backend-user-list');
76 
77  // We expect exact one fitting Backend User created from the Fixtures
78  $this->‪checkCountOfUsers($I, 1);
79 
80  $I->wantTo('Filter the list of user by valid username administrator');
81  $I->fillField('#tx_Beuser_username', 'administrator');
82  $I->click('Filter');
83  $I->waitForElementNotVisible('div#nprogess');
84  $I->waitForElementVisible('#typo3-backend-user-list');
85 
86  // We expect exact no fitting Backend User created from the Fixtures
87  $this->‪checkCountOfUsers($I, 0);
88  }
89 
90  public function ‪filterUsersByAdmin(‪ApplicationTester $I, Scenario $scenario): void
91  {
92  $I->wantTo('See the table of users');
93  $I->waitForElementVisible('#typo3-backend-user-list');
94  $I->click('button[value="reset-filters"]');
95  $I->waitForElementVisible('#typo3-backend-user-list');
96  $isComposerMode = str_contains($scenario->current('env'), 'composer');
97  $expectedUsers = 4;
98  if ($isComposerMode) {
99  $expectedUsers++;
100  }
101  $I->canSeeNumberOfElements('#typo3-backend-user-list tbody tr', $expectedUsers);
102 
103  $I->wantToTest('Filter BackendUser and see only admins');
104  $I->selectOption('#tx_Beuser_usertype', 'Admin only');
105  $I->click('Filter');
106  $I->waitForElementNotVisible('div#nprogess');
107  $I->waitForElementVisible('#typo3-backend-user-list');
108 
109  // We expect exact two (composer-mode: three) fitting Backend Users created from the Fixtures
110  $this->‪checkCountOfUsers($I, 2 + ($isComposerMode ? 1 : 0));
111 
112  $I->wantToTest('Filter BackendUser and see normal users');
113  $I->selectOption('#tx_Beuser_usertype', 'Normal users only');
114  $I->click('Filter');
115  $I->waitForElementNotVisible('div#nprogess');
116  $I->waitForElementVisible('#typo3-backend-user-list');
117 
118  // We expect exact two fitting Backend Users created from the Fixtures
119  $this->‪checkCountOfUsers($I, 2);
120  }
121 
122  public function ‪filterUsersByStatus(‪ApplicationTester $I, Scenario $scenario): void
123  {
124  $I->wantTo('See the table of users');
125  $I->waitForElementVisible('#typo3-backend-user-list');
126  $I->click('button[value="reset-filters"]');
127  $I->waitForElementVisible('#typo3-backend-user-list');
128  $isComposerMode = str_contains($scenario->current('env'), 'composer');
129  $expectedUsers = 4;
130  if ($isComposerMode) {
131  $expectedUsers++;
132  }
133  $I->canSeeNumberOfElements('#typo3-backend-user-list tbody tr', $expectedUsers);
134 
135  $I->wantToTest('Filter BackendUser and see only active users');
136  $I->selectOption('#tx_Beuser_status', 'Active only');
137  $I->click('Filter');
138  $I->waitForElementNotVisible('div#nprogess');
139  $I->waitForElementVisible('#typo3-backend-user-list');
140 
141  // We expect exact two (composer-mode three) fitting Backend Users created from the Fixtures
142  $this->‪checkCountOfUsers($I, 2 + ($isComposerMode ? 1 : 0));
143 
144  $I->wantToTest('Filter BackendUser and see only inactive users');
145  $I->selectOption('#tx_Beuser_status', 'Inactive only');
146  $I->click('Filter');
147  $I->waitForElementNotVisible('div#nprogess');
148  $I->waitForElementVisible('#typo3-backend-user-list');
149 
150  // We expect exact two fitting Backend Users created from the Fixtures
151  $this->‪checkCountOfUsers($I, 2);
152  }
153 
154  public function ‪filterUsersByLogin(‪ApplicationTester $I, Scenario $scenario): void
155  {
156  $I->wantTo('See the table of users');
157  $I->waitForElementVisible('#typo3-backend-user-list');
158  $I->click('button[value="reset-filters"]');
159  $I->waitForElementVisible('#typo3-backend-user-list');
160  $isComposerMode = str_contains($scenario->current('env'), 'composer');
161  $expectedUsers = 4;
162  if ($isComposerMode) {
163  $expectedUsers++;
164  }
165  $I->canSeeNumberOfElements('#typo3-backend-user-list tbody tr', $expectedUsers);
166 
167  $I->wantToTest('Filter BackendUser and see only users logged in before');
168  $I->selectOption('#tx_Beuser_logins', 'Logged in before');
169  $I->click('Filter');
170  $I->waitForElementNotVisible('div#nprogess');
171  $I->waitForElementVisible('#typo3-backend-user-list');
172 
173  // We expect exact two fitting Backend Users created from the Fixtures
174  $this->‪checkCountOfUsers($I, 2);
175 
176  $I->wantToTest('Filter BackendUser and see only users never logged in before');
177  $I->selectOption('#tx_Beuser_logins', 'Never logged in');
178  $I->click('Filter');
179  $I->waitForElementNotVisible('div#nprogess');
180  $I->waitForElementVisible('#typo3-backend-user-list');
181 
182  // We expect exact two (composer-mode three) fitting Backend Users created from the Fixtures
183  $this->‪checkCountOfUsers($I, 2 + ($isComposerMode ? 1 : 0));
184  }
185 
186  public function ‪filterUsersByUserGroup(‪ApplicationTester $I, Scenario $scenario): void
187  {
188  $I->wantTo('See the table of users');
189  $I->waitForElementVisible('#typo3-backend-user-list');
190  $I->click('button[value="reset-filters"]');
191  $I->waitForElementVisible('#typo3-backend-user-list');
192  $isComposerMode = str_contains($scenario->current('env'), 'composer');
193  $expectedUsers = 4;
194  if ($isComposerMode) {
195  $expectedUsers++;
196  }
197  $I->canSeeNumberOfElements('#typo3-backend-user-list tbody tr', $expectedUsers);
198 
199  // We expect exact one Backend Users created from the Fixtures has the usergroup named 'editor-group'
200  $I->wantToTest('Filter BackendUser and see only users with given usergroup');
201  $I->selectOption('#tx_beuser_backendUserGroup', 'editor-group');
202  $I->click('Filter');
203  $I->waitForElementNotVisible('div#nprogess');
204  $I->waitForElementVisible('#typo3-backend-user-list');
205 
206  // We expect exact one fitting Backend User created from the Fixtures
207  $this->‪checkCountOfUsers($I, 1);
208  }
209 
211  {
212  $I->canSee('Backend users', 'h1');
213  $I->waitForElementVisible('#typo3-backend-user-list');
214  $I->click('button[value="reset-filters"]');
215  $I->waitForElementVisible('#typo3-backend-user-list');
216  $username = 'admin';
217  $adminRow = '//*[@id="typo3-backend-user-list"]//tr[contains(td[2]/a[1]/b[1], "' . $username . '")]';
218 
219  $I->amGoingTo('test the edit button');
220  $I->click($adminRow . '//div[@role="group"]/a[@title="Edit"]');
221  $this->‪openAndCloseTheEditForm($I, $username);
222 
223  $I->amGoingTo('test the edit link on username');
224  $I->click($adminRow . '//td[@class="col-title"]/a[1]');
225  $this->‪openAndCloseTheEditForm($I, $username);
226 
227  $I->amGoingTo('test the edit link on real name');
228  $I->click($adminRow . '//td[@class="col-title"]/a[2]');
229  $this->‪openAndCloseTheEditForm($I, $username);
230  }
231 
232  private function ‪checkCountOfUsers(‪ApplicationTester $I, int $countOfUsers): void
233  {
234  $I->canSeeNumberOfElements('#typo3-backend-user-list tbody tr', $countOfUsers);
235  $I->wantToTest('If a number of users is shown in the footer row');
236  $I->canSeeNumberOfElements('#typo3-backend-user-list tfoot tr', 1);
237  $I->see($countOfUsers . ' User', '#typo3-backend-user-list tfoot tr');
238  }
239 
240  private function ‪openAndCloseTheEditForm(‪ApplicationTester $I, string $username): void
241  {
242  $I->waitForElementNotVisible('#t3js-ui-block');
243  $I->canSee('Edit Backend user "' . $username . '" on root level');
244 
245  $I->click('div.module-docheader .btn.t3js-editform-close');
246  $I->waitForElementVisible('table.table-striped');
247  $I->canSee('Backend users', 'h1');
248  }
249 }
‪TYPO3\CMS\Core\Tests\Acceptance\Application\BackendUser\ListUserCest\filterUsersByUserGroup
‪filterUsersByUserGroup(ApplicationTester $I, Scenario $scenario)
Definition: ListUserCest.php:186
‪TYPO3\CMS\Core\Tests\Acceptance\Support\ApplicationTester
Definition: ApplicationTester.php:28
‪TYPO3\CMS\Core\Tests\Acceptance\Application\BackendUser\ListUserCest\showsHeadingAndListsBackendUsers
‪showsHeadingAndListsBackendUsers(ApplicationTester $I, Scenario $scenario)
Definition: ListUserCest.php:38
‪TYPO3\CMS\Core\Tests\Acceptance\Application\BackendUser\ListUserCest\filterUsersByAdmin
‪filterUsersByAdmin(ApplicationTester $I, Scenario $scenario)
Definition: ListUserCest.php:90
‪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:122
‪TYPO3\CMS\Core\Tests\Acceptance\Application\BackendUser\ListUserCest\openAndCloseTheEditForm
‪openAndCloseTheEditForm(ApplicationTester $I, string $username)
Definition: ListUserCest.php:240
‪TYPO3\CMS\Core\Tests\Acceptance\Application\BackendUser
Definition: CompareUserCest.php:18
‪TYPO3\CMS\Core\Tests\Acceptance\Application\BackendUser\ListUserCest\canEditUsersFromIndexListView
‪canEditUsersFromIndexListView(ApplicationTester $I)
Definition: ListUserCest.php:210
‪TYPO3\CMS\Core\Tests\Acceptance\Application\BackendUser\ListUserCest\filterUsersByUsername
‪filterUsersByUsername(ApplicationTester $I, Scenario $scenario)
Definition: ListUserCest.php:58
‪TYPO3\CMS\Core\Tests\Acceptance\Application\BackendUser\ListUserCest\_before
‪_before(ApplicationTester $I)
Definition: ListUserCest.php:28
‪TYPO3\CMS\Core\Tests\Acceptance\Application\BackendUser\ListUserCest\filterUsersByLogin
‪filterUsersByLogin(ApplicationTester $I, Scenario $scenario)
Definition: ListUserCest.php:154
‪TYPO3\CMS\Core\Tests\Acceptance\Application\BackendUser\ListUserCest\checkCountOfUsers
‪checkCountOfUsers(ApplicationTester $I, int $countOfUsers)
Definition: ListUserCest.php:232