1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?php
- class LoginFormCest
- {
- public function _before(\FunctionalTester $I)
- {
- $I->amOnRoute('site/login');
- }
- public function openLoginPage(\FunctionalTester $I)
- {
- $I->see('Login', 'h1');
- }
- // demonstrates `amLoggedInAs` method
- public function internalLoginById(\FunctionalTester $I)
- {
- $I->amLoggedInAs(100);
- $I->amOnPage('/');
- $I->see('Logout (admin)');
- }
- // demonstrates `amLoggedInAs` method
- public function internalLoginByInstance(\FunctionalTester $I)
- {
- $I->amLoggedInAs(\app\models\User::findByUsername('admin'));
- $I->amOnPage('/');
- $I->see('Logout (admin)');
- }
- public function loginWithEmptyCredentials(\FunctionalTester $I)
- {
- $I->submitForm('#login-form', []);
- $I->expectTo('see validations errors');
- $I->see('Username cannot be blank.');
- $I->see('Password cannot be blank.');
- }
- public function loginWithWrongCredentials(\FunctionalTester $I)
- {
- $I->submitForm('#login-form', [
- 'LoginForm[username]' => 'admin',
- 'LoginForm[password]' => 'wrong',
- ]);
- $I->expectTo('see validations errors');
- $I->see('Incorrect username or password.');
- }
- public function loginSuccessfully(\FunctionalTester $I)
- {
- $I->submitForm('#login-form', [
- 'LoginForm[username]' => 'admin',
- 'LoginForm[password]' => 'admin',
- ]);
- $I->see('Logout (admin)');
- $I->dontSeeElement('form#login-form');
- }
- }
|