LoginCept.php 1.21 KB
Newer Older
1 2
<?php

3 4
use tests\codeception\backend\AcceptanceTester;
use tests\codeception\common\_pages\LoginPage;
5

6
$I = new AcceptanceTester($scenario);
7 8 9 10 11 12
$I->wantTo('ensure login page works');

$loginPage = LoginPage::openBy($I);

$I->amGoingTo('submit login form with no data');
$loginPage->login('', '');
13 14 15
if (method_exists($I, 'wait')) {
    $I->wait(3); // only for selenium
}
16
$I->expectTo('see validations errors');
Johnny Theill committed
17 18
$I->see('Username cannot be blank.', '.help-block');
$I->see('Password cannot be blank.', '.help-block');
19 20 21 22

$I->amGoingTo('try to login with wrong credentials');
$I->expectTo('see validations errors');
$loginPage->login('admin', 'wrong');
23 24 25
if (method_exists($I, 'wait')) {
    $I->wait(3); // only for selenium
}
26
$I->expectTo('see validations errors');
Johnny Theill committed
27
$I->see('Incorrect username or password.', '.help-block');
28 29 30

$I->amGoingTo('try to login with correct credentials');
$loginPage->login('erau', 'password_0');
31 32 33
if (method_exists($I, 'wait')) {
    $I->wait(3); // only for selenium
}
34
$I->expectTo('see that user is logged');
Johnny Theill committed
35 36 37 38 39 40 41 42
$I->seeLink('Logout (erau)');
$I->dontSeeLink('Login');
$I->dontSeeLink('Signup');
/** Uncomment if using WebDriver
 * $I->click('Logout (erau)');
 * $I->dontSeeLink('Logout (erau)');
 * $I->seeLink('Login');
 */