Skip to content

Commit

Permalink
Add failed tests for login.
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Dec 8, 2023
1 parent ef1fdf2 commit 8c441c2
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions tests/Acceptance/LoginCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,58 @@ public function allowLoginByIpsFailed(AcceptanceTester $I): void
$I->allowLogin(true, []);
}

public function failedWithEmail(AcceptanceTester $I): void
{
$I->wantTo('security login username submit form success data.');
$I->haveFixtures([Account::class => AccountFixture::class]);
$account = $I->grabFixture(Account::class, 'confirmed');

$I->amGoingTo('navigate to the login page.');
$I->amOnRoute('login/index');

$I->wantTo('ensure that login page works.');
$I->expectTo('see page index.');
$I->see(Yii::t('yii.user', 'Sign in'), 'h1');
$I->see(Yii::t('yii.user', 'Please fill out the following fields to Sign in.'));

$I->expectTo('fill in the form.');
$I->fillField('#loginform-login', $account->email);
$I->fillField('#loginform-password', '12345678');
$I->click(Yii::t('yii.user', 'Sign in'));

$I->expectTo('see message validation.');
$I->see(Yii::t('yii.user', 'Invalid login or password.'));

$I->expectTo('see that the user is logged in.');
$I->dontSeeLink(Yii::t('yii.user', 'Logout'));
}

public function failedWithUsername(AcceptanceTester $I): void
{
$I->wantTo('security login username submit form success data.');
$I->haveFixtures([Account::class => AccountFixture::class]);
$account = $I->grabFixture(Account::class, 'confirmed');

$I->amGoingTo('navigate to the login page.');
$I->amOnRoute('login/index');

$I->wantTo('ensure that login page works.');
$I->expectTo('see page index.');
$I->see(Yii::t('yii.user', 'Sign in'), 'h1');
$I->see(Yii::t('yii.user', 'Please fill out the following fields to Sign in.'));

$I->expectTo('fill in the form.');
$I->fillField('#loginform-login', $account->username);
$I->fillField('#loginform-password', '12345678');
$I->click(Yii::t('yii.user', 'Sign in'));

$I->expectTo('see message validation.');
$I->see(Yii::t('yii.user', 'Invalid login or password.'));

$I->expectTo('see that the user is logged in.');
$I->dontSeeLink(Yii::t('yii.user', 'Logout'));
}

public function indexPage(AcceptanceTester $I): void
{
$I->amGoingTo('navigate to the login page.');
Expand Down

0 comments on commit 8c441c2

Please sign in to comment.