TYPO3 CMS  TYPO3_8-7
BackendLoginCest.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
19 
24 {
31  public function loginButtonMouseOver(BackendTester $I)
32  {
33  $I->wantTo('check login functions');
34  $I->amOnPage('/typo3/index.php');
35  $I->waitForElement('#t3-username', 10);
36  $I->wantTo('mouse over css change login button');
37 
38  // Make sure mouse is not over submit button from a previous test
39  $I->moveMouseOver('#t3-username');
40  $bs = $I->executeInSelenium(function (\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) {
41  return $webdriver->findElement(\WebDriverBy::cssSelector('#t3-login-submit'))->getCSSValue('box-shadow');
42  });
43 
44  $I->moveMouseOver('#t3-login-submit');
45  $I->wait(1);
46  $bsmo = $I->executeInSelenium(function (\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) {
47  return $webdriver->findElement(\WebDriverBy::cssSelector('#t3-login-submit'))->getCSSValue('box-shadow');
48  });
49  $I->assertFalse($bs === $bsmo);
50  }
51 
59  {
60  $I->wantTo('check login functions');
61  $I->amOnPage('/typo3/index.php');
62  $I->waitForElement('#t3-username');
63 
64  $I->wantTo('check empty credentials');
65  $required = $I->executeInSelenium(function (\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) {
66  return $webdriver->findElement(\WebDriverBy::cssSelector('#t3-username'))->getAttribute('required');
67  });
68  $I->assertEquals('true', $required, '#t3-username');
69 
70  $required = $I->executeInSelenium(function (\Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) {
71  return $webdriver->findElement(\WebDriverBy::cssSelector('#t3-password'))->getAttribute('required');
72  });
73  $I->assertEquals('true', $required, '#t3-password');
74 
75  $I->wantTo('use bad credentials');
76  $I->fillField('#t3-username', 'testify');
77  $I->fillField('#t3-password', '123456');
78  $I->click('#t3-login-submit-section > button');
79  $I->waitForElement('#t3-login-error', 30);
80  $I->see('Your login attempt did not succeed');
81  }
82 
89  {
90  $I->wantTo('login with admin');
91  $this->login($I, 'admin', 'password');
92 
93  // user is redirected to 'about modules' after login, and must see the 'admin tools' section
94  $I->see('Admin tools');
95 
96  $this->logout($I);
97  $I->waitForElement('#t3-username');
98  }
99 
106  {
107  $this->login($I, 'editor', 'password');
108 
109  // user is redirected to 'about modules' after login, but must not see the 'admin tools' section
110  $I->cantSee('Admin tools', '#menu');
111 
112  $topBarItemSelector = Topbar::$containerSelector . ' ' . Topbar::$dropdownToggleSelector . ' *';
113 
114  // can see bookmarks
115  $I->seeElement($topBarItemSelector, ['title' => 'Bookmarks']);
116 
117  // can't see clear cache
118  $I->cantSeeElement($topBarItemSelector, ['title' => 'Clear cache']);
119 
120  $this->logout($I);
121  $I->waitForElement('#t3-username');
122  }
123 
131  protected function login(BackendTester $I, string $username, string $password)
132  {
133  $I->amGoingTo('Step\Backend\Login username: ' . $username);
134  $I->amOnPage('/typo3/index.php');
135  $I->waitForElement('#t3-username');
136  $I->fillField('#t3-username', $username);
137  $I->fillField('#t3-password', $password);
138  $I->click('#t3-login-submit-section > button');
139  // wait for the next to element to indicate if the backend was loaded successful
140  $I->waitForElement('.nav', 30);
141  $I->waitForElement('.scaffold-content iframe', 30);
142  $I->seeCookie('be_lastLoginProvider');
143  $I->seeCookie('be_typo_user');
144  }
145 
151  protected function logout(BackendTester $I)
152  {
153  $I->amGoingTo('step backend login');
154  $I->amGoingTo('logout');
155  // ensure that we are on the main frame
156  $I->switchToMainFrame();
157  $I->click('#typo3-cms-backend-backend-toolbaritems-usertoolbaritem > a');
158  $I->click('Logout');
159  $I->waitForElement('#t3-username');
160  }
161 }
login(BackendTester $I, string $username, string $password)