‪TYPO3CMS  10.4
BackendLoginCest.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 
21 use TYPO3\TestingFramework\Core\Acceptance\Helper\Topbar;
22 
27 {
35  {
36  $I->wantTo('check login functions');
37  $I->amOnPage('/typo3/index.php');
38  $I->waitForElement('#t3-username', 10);
39  $I->wantTo('mouse over css change login button');
40 
41  // Make sure mouse is not over submit button from a previous test
42  $I->moveMouseOver('#t3-username');
43  $bs = $I->executeInSelenium(function (\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) {
44  return $webdriver->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('#t3-login-submit'))->getCSSValue('box-shadow');
45  });
46 
47  $I->moveMouseOver('#t3-login-submit');
48  $I->wait(1);
49  $bsmo = $I->executeInSelenium(function (\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) {
50  return $webdriver->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('#t3-login-submit'))->getCSSValue('box-shadow');
51  });
52  $I->assertFalse($bs === $bsmo);
53  }
54 
62  {
63  $I->wantTo('check login functions');
64  $I->amOnPage('/typo3/index.php');
65  $I->waitForElement('#t3-username');
66 
67  $I->wantTo('check empty credentials');
68  $required = $I->executeInSelenium(function (\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) {
69  return $webdriver->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('#t3-username'))->getAttribute('required');
70  });
71  $I->assertEquals('true', $required, '#t3-username');
72 
73  $required = $I->executeInSelenium(function (\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) {
74  return $webdriver->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('#t3-password'))->getAttribute('required');
75  });
76  $I->assertEquals('true', $required, '#t3-password');
77 
78  $I->wantTo('use bad credentials');
79  $I->fillField('#t3-username', 'testify');
80  $I->fillField('#t3-password', '123456');
81  $I->click('#t3-login-submit-section > button');
82  $I->waitForElement('#t3-login-error', 30);
83  $I->see('Your login attempt did not succeed');
84  }
85 
92  {
93  $I->wantTo('login with admin');
94  $this->‪login($I, 'admin', 'password');
95 
96  // user must see the 'System' section in module menu
97  $I->see('System', '#modulemenu');
98 
99  $this->‪logout($I);
100  $I->waitForElement('#t3-username');
101  }
102 
109  {
110  $this->‪login($I, 'editor', 'password');
111 
112  // user must not see the 'System' section in module menu
113  $I->cantSee('System', '#modulemenu');
114 
115  $topBarItemSelector = Topbar::$containerSelector . ' ' . Topbar::$dropdownToggleSelector . ' *';
116 
117  // can see bookmarks
118  $I->seeElement($topBarItemSelector, ['title' => 'Bookmarks']);
119 
120  // can't see clear cache
121  $I->cantSeeElement($topBarItemSelector, ['title' => 'Clear cache']);
122 
123  $this->‪logout($I);
124  $I->waitForElement('#t3-username');
125  }
126 
134  protected function ‪login(‪BackendTester $I, string $username, string $password)
135  {
136  $I->amGoingTo('Step\Backend\Login username: ' . $username);
137  $I->amOnPage('/typo3/index.php');
138  $I->waitForElement('#t3-username');
139  $I->fillField('#t3-username', $username);
140  $I->fillField('#t3-password', $password);
141  $I->click('#t3-login-submit-section > button');
142  // wait for the next to element to indicate if the backend was loaded successful
143  if ($username !== 'editor') {
144  // "editor" doesn't have any modules available in this setup
145  $I->waitForElement('.scaffold-modulemenu', 30);
146  }
147  $I->waitForElement('.scaffold-content iframe', 30);
148  $I->seeCookie('be_typo_user');
149  }
150 
156  protected function ‪logout(‪BackendTester $I)
157  {
158  $I->amGoingTo('step backend login');
159  $I->amGoingTo('logout');
160  // ensure that we are on the main frame
161  $I->switchToMainFrame();
162  $I->click('#typo3-cms-backend-backend-toolbaritems-usertoolbaritem > a');
163  $I->click('Logout');
164  $I->waitForElement('#t3-username');
165  }
166 }
‪TYPO3\CMS\Core\Tests\Acceptance\Backend\Login\BackendLoginCest\loginButtonMouseOver
‪loginButtonMouseOver(BackendTester $I)
Definition: BackendLoginCest.php:34
‪TYPO3\CMS\Core\Tests\Acceptance\Backend\Login
Definition: BackendLoginCest.php:18
‪TYPO3\CMS\Core\Tests\Acceptance\Backend\Login\BackendLoginCest\login
‪login(BackendTester $I, string $username, string $password)
Definition: BackendLoginCest.php:134
‪TYPO3\CMS\Core\Tests\Acceptance\Backend\Login\BackendLoginCest
Definition: BackendLoginCest.php:27
‪TYPO3\CMS\Core\Tests\Acceptance\Backend\Login\BackendLoginCest\loginWorksAsAdminUser
‪loginWorksAsAdminUser(BackendTester $I)
Definition: BackendLoginCest.php:91
‪TYPO3\CMS\Core\Tests\Acceptance\Support\BackendTester
Definition: BackendTester.php:27
‪TYPO3\CMS\Core\Tests\Acceptance\Backend\Login\BackendLoginCest\logout
‪logout(BackendTester $I)
Definition: BackendLoginCest.php:156
‪TYPO3\CMS\Core\Tests\Acceptance\Backend\Login\BackendLoginCest\loginDeniedWithInvalidCredentials
‪loginDeniedWithInvalidCredentials(BackendTester $I)
Definition: BackendLoginCest.php:61
‪TYPO3\CMS\Core\Tests\Acceptance\Backend\Login\BackendLoginCest\loginWorksAsEditorUser
‪loginWorksAsEditorUser(BackendTester $I)
Definition: BackendLoginCest.php:108