first commit
This commit is contained in:
66
frontend/tests/functional/LoginCest.php
Executable file
66
frontend/tests/functional/LoginCest.php
Executable file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\tests\functional;
|
||||
|
||||
use frontend\tests\FunctionalTester;
|
||||
use common\fixtures\UserFixture;
|
||||
|
||||
class LoginCest
|
||||
{
|
||||
/**
|
||||
* Load fixtures before db transaction begin
|
||||
* Called in _before()
|
||||
* @see \Codeception\Module\Yii2::_before()
|
||||
* @see \Codeception\Module\Yii2::loadFixtures()
|
||||
* @return array
|
||||
*/
|
||||
public function _fixtures()
|
||||
{
|
||||
return [
|
||||
'user' => [
|
||||
'class' => UserFixture::class,
|
||||
'dataFile' => codecept_data_dir() . 'login_data.php',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function _before(FunctionalTester $I)
|
||||
{
|
||||
$I->amOnRoute('site/login');
|
||||
}
|
||||
|
||||
protected function formParams($login, $password)
|
||||
{
|
||||
return [
|
||||
'LoginForm[username]' => $login,
|
||||
'LoginForm[password]' => $password,
|
||||
];
|
||||
}
|
||||
|
||||
public function checkEmpty(FunctionalTester $I)
|
||||
{
|
||||
$I->submitForm('#login-form', $this->formParams('', ''));
|
||||
$I->seeValidationError('Username cannot be blank.');
|
||||
$I->seeValidationError('Password cannot be blank.');
|
||||
}
|
||||
|
||||
public function checkWrongPassword(FunctionalTester $I)
|
||||
{
|
||||
$I->submitForm('#login-form', $this->formParams('admin', 'wrong'));
|
||||
$I->seeValidationError('Incorrect username or password.');
|
||||
}
|
||||
|
||||
public function checkInactiveAccount(FunctionalTester $I)
|
||||
{
|
||||
$I->submitForm('#login-form', $this->formParams('test.test', 'Test1234'));
|
||||
$I->seeValidationError('Incorrect username or password');
|
||||
}
|
||||
|
||||
public function checkValidLogin(FunctionalTester $I)
|
||||
{
|
||||
$I->submitForm('#login-form', $this->formParams('erau', 'password_0'));
|
||||
$I->see('Logout (erau)', 'form button[type=submit]');
|
||||
$I->dontSeeLink('Login');
|
||||
$I->dontSeeLink('Signup');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user