ctms/dacms-api/tests/functional/LoginCest.php
2025-04-10 23:19:13 +08:00

50 lines
1.3 KiB
PHP
Executable File

<?php
namespace frontend\tests\functional;
use frontend\tests\FunctionalTester;
use common\fixtures\User as UserFixture;
class LoginCest
{
function _before(FunctionalTester $I)
{
$I->haveFixtures([
'user' => [
'class' => UserFixture::className(),
'dataFile' => codecept_data_dir() . 'login_data.php'
]
]);
$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 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');
}
}