‪TYPO3CMS  11.5
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 {
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(static function (\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) {
42  return $webdriver->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('#t3-login-submit'))->getCSSValue('background-color');
43  });
44 
45  $I->moveMouseOver('#t3-login-submit');
46  $I->wait(1);
47  $bsmo = $I->executeInSelenium(static function (\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) {
48  return $webdriver->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('#t3-login-submit'))->getCSSValue('background-color');
49  });
50  $I->assertNotSame($bs, $bsmo);
51  }
52 
58  {
59  $I->wantTo('check login functions');
60  $I->amOnPage('/typo3/index.php');
61  $I->waitForElement('#t3-username');
62 
63  $I->wantTo('check empty credentials');
64  $required = $I->executeInSelenium(static function (\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) {
65  return $webdriver->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('#t3-username'))->getAttribute('required');
66  });
67  $I->assertEquals('true', $required, '#t3-username');
68 
69  $required = $I->executeInSelenium(static function (\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) {
70  return $webdriver->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('#t3-password'))->getAttribute('required');
71  });
72  $I->assertEquals('true', $required, '#t3-password');
73 
74  $I->wantTo('use bad credentials');
75  $I->fillField('#t3-username', 'testify');
76  $I->fillField('#t3-password', '123456');
77  $I->click('#t3-login-submit-section > button');
78  $I->waitForElement('#t3-login-error', 30);
79  $I->see('Your login attempt did not succeed');
80  }
81 
86  {
87  $I->wantTo('login with admin');
88  $this->‪login($I, 'admin', 'password');
89 
90  // user must see the 'System' section in module menu
91  $I->see('System', '#modulemenu');
92 
93  $this->‪logout($I);
94  $I->waitForElement('#t3-username');
95  }
96 
101  {
102  $this->‪login($I, 'editor', 'password');
103 
104  // user must not see the 'System' section in module menu
105  $I->cantSee('System', '#modulemenu');
106 
107  $topBarItemSelector = Topbar::$containerSelector . ' ' . Topbar::$dropdownToggleSelector . ' *';
108 
109  // can see bookmarks
110  $I->seeElement($topBarItemSelector, ['title' => 'Bookmarks']);
111 
112  // can't see clear cache
113  $I->cantSeeElement($topBarItemSelector, ['title' => 'Clear cache']);
114 
115  $this->‪logout($I);
116  $I->waitForElement('#t3-username');
117  }
118 
122  protected function ‪login(‪ApplicationTester $I, string $username, string $password): void
123  {
124  $I->amGoingTo('Step\Application\Login username: ' . $username);
125  $I->amOnPage('/typo3/index.php');
126  $I->waitForElement('#t3-username');
127  $I->fillField('#t3-username', $username);
128  $I->fillField('#t3-password', $password);
129  $I->click('#t3-login-submit-section > button');
130  // wait for the next to element to indicate if the backend was loaded successful
131  if ($username !== 'editor') {
132  // "editor" doesn't have any modules available in this setup
133  $I->waitForElement('.scaffold-modulemenu', 30);
134  }
135  $I->waitForElement('.scaffold-content iframe', 30);
136  $I->seeCookie('be_typo_user');
137  }
138 
142  protected function ‪logout(‪ApplicationTester $I): void
143  {
144  $I->amGoingTo('step backend login');
145  $I->amGoingTo('logout');
146  // ensure that we are on the main frame
147  $I->switchToMainFrame();
148  $I->click('#typo3-cms-backend-backend-toolbaritems-usertoolbaritem > a');
149  $I->click('Logout');
150  $I->waitForElement('#t3-username');
151  }
152 }
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Login\BackendLoginCest\loginWorksAsEditorUser
‪loginWorksAsEditorUser(ApplicationTester $I)
Definition: BackendLoginCest.php:100
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Login\BackendLoginCest\logout
‪logout(ApplicationTester $I)
Definition: BackendLoginCest.php:142
‪TYPO3\CMS\Core\Tests\Acceptance\Support\ApplicationTester
Definition: ApplicationTester.php:27
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Login\BackendLoginCest\loginButtonMouseOver
‪loginButtonMouseOver(ApplicationTester $I)
Definition: BackendLoginCest.php:32
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Login\BackendLoginCest\login
‪login(ApplicationTester $I, string $username, string $password)
Definition: BackendLoginCest.php:122
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Login\BackendLoginCest
Definition: BackendLoginCest.php:27
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Login\BackendLoginCest\loginWorksAsAdminUser
‪loginWorksAsAdminUser(ApplicationTester $I)
Definition: BackendLoginCest.php:85
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Login
Definition: BackendLoginCest.php:18
‪TYPO3\CMS\Core\Tests\Acceptance\Application\Login\BackendLoginCest\loginDeniedWithInvalidCredentials
‪loginDeniedWithInvalidCredentials(ApplicationTester $I)
Definition: BackendLoginCest.php:57