‪TYPO3CMS  9.5
BackendLoginCest.php
Go to the documentation of this file.
1 <?php
2 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 use TYPO3\TestingFramework\Core\Acceptance\Helper\Topbar;
20 
25 {
33  {
34  $I->wantTo('check login functions');
35  $I->amOnPage('/typo3/index.php');
36  $I->waitForElement('#t3-username', 10);
37  $I->wantTo('mouse over css change login button');
38 
39  // Make sure mouse is not over submit button from a previous test
40  $I->moveMouseOver('#t3-username');
41  $bs = $I->executeInSelenium(function (\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) {
42  return $webdriver->findElement(\WebDriverBy::cssSelector('#t3-login-submit'))->getCSSValue('box-shadow');
43  });
44 
45  $I->moveMouseOver('#t3-login-submit');
46  $I->wait(1);
47  $bsmo = $I->executeInSelenium(function (\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) {
48  return $webdriver->findElement(\WebDriverBy::cssSelector('#t3-login-submit'))->getCSSValue('box-shadow');
49  });
50  $I->assertFalse($bs === $bsmo);
51  }
52 
60  {
61  $I->wantTo('check login functions');
62  $I->amOnPage('/typo3/index.php');
63  $I->waitForElement('#t3-username');
64 
65  $I->wantTo('check empty credentials');
66  $required = $I->executeInSelenium(function (\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) {
67  return $webdriver->findElement(\WebDriverBy::cssSelector('#t3-username'))->getAttribute('required');
68  });
69  $I->assertEquals('true', $required, '#t3-username');
70 
71  $required = $I->executeInSelenium(function (\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) {
72  return $webdriver->findElement(\WebDriverBy::cssSelector('#t3-password'))->getAttribute('required');
73  });
74  $I->assertEquals('true', $required, '#t3-password');
75 
76  $I->wantTo('use bad credentials');
77  $I->fillField('#t3-username', 'testify');
78  $I->fillField('#t3-password', '123456');
79  $I->click('#t3-login-submit-section > button');
80  $I->waitForElement('#t3-login-error', 30);
81  $I->see('Your login attempt did not succeed');
82  }
83 
90  {
91  $I->wantTo('login with admin');
92  $this->‪login($I, 'admin', 'password');
93 
94  // user is redirected to 'about modules' after login, and must see the 'admin tools' section
95  $I->see('Admin tools');
96 
97  $this->‪logout($I);
98  $I->waitForElement('#t3-username');
99  }
100 
107  {
108  $this->‪login($I, 'editor', 'password');
109 
110  // user is redirected to 'about modules' after login, but must not see the 'admin tools' section
111  $I->cantSee('Admin tools', '#menu');
112 
113  $topBarItemSelector = Topbar::$containerSelector . ' ' . Topbar::$dropdownToggleSelector . ' *';
114 
115  // can see bookmarks
116  $I->seeElement($topBarItemSelector, ['title' => 'Bookmarks']);
117 
118  // can't see clear cache
119  $I->cantSeeElement($topBarItemSelector, ['title' => 'Clear cache']);
120 
121  $this->‪logout($I);
122  $I->waitForElement('#t3-username');
123  }
124 
132  protected function ‪login(‪BackendTester $I, string $username, string $password)
133  {
134  $I->amGoingTo('Step\Backend\Login username: ' . $username);
135  $I->amOnPage('/typo3/index.php');
136  $I->waitForElement('#t3-username');
137  $I->fillField('#t3-username', $username);
138  $I->fillField('#t3-password', $password);
139  $I->click('#t3-login-submit-section > button');
140  // wait for the next to element to indicate if the backend was loaded successful
141  $I->waitForElement('.nav', 30);
142  $I->waitForElement('.scaffold-content iframe', 30);
143  $I->seeCookie('be_lastLoginProvider');
144  $I->seeCookie('be_typo_user');
145  }
146 
152  protected function ‪logout(‪BackendTester $I)
153  {
154  $I->amGoingTo('step backend login');
155  $I->amGoingTo('logout');
156  // ensure that we are on the main frame
157  $I->switchToMainFrame();
158  $I->click('#typo3-cms-backend-backend-toolbaritems-usertoolbaritem > a');
159  $I->click('Logout');
160  $I->waitForElement('#t3-username');
161  }
162 }
‪TYPO3\CMS\Core\Tests\Acceptance\Backend\Login\BackendLoginCest\loginButtonMouseOver
‪loginButtonMouseOver(BackendTester $I)
Definition: BackendLoginCest.php:32
‪TYPO3\CMS\Core\Tests\Acceptance\Backend\Login
Definition: BackendLoginCest.php:3
‪TYPO3\CMS\Core\Tests\Acceptance\Backend\Login\BackendLoginCest\login
‪login(BackendTester $I, string $username, string $password)
Definition: BackendLoginCest.php:132
‪TYPO3\CMS\Core\Tests\Acceptance\Backend\Login\BackendLoginCest
Definition: BackendLoginCest.php:25
‪TYPO3\CMS\Core\Tests\Acceptance\Backend\Login\BackendLoginCest\loginWorksAsAdminUser
‪loginWorksAsAdminUser(BackendTester $I)
Definition: BackendLoginCest.php:89
‪TYPO3\CMS\Core\Tests\Acceptance\Support\BackendTester
Definition: BackendTester.php:25
‪TYPO3\CMS\Core\Tests\Acceptance\Backend\Login\BackendLoginCest\logout
‪logout(BackendTester $I)
Definition: BackendLoginCest.php:152
‪TYPO3\CMS\Core\Tests\Acceptance\Backend\Login\BackendLoginCest\loginDeniedWithInvalidCredentials
‪loginDeniedWithInvalidCredentials(BackendTester $I)
Definition: BackendLoginCest.php:59
‪TYPO3\CMS\Core\Tests\Acceptance\Backend\Login\BackendLoginCest\loginWorksAsEditorUser
‪loginWorksAsEditorUser(BackendTester $I)
Definition: BackendLoginCest.php:106