yii2-netdisk/tests/functional/LoginFormCest.php

41 lines
1.1 KiB
PHP
Raw Normal View History

2016-07-16 09:13:51 +08:00
<?php
class LoginFormCest
{
public function _before(\FunctionalTester $I)
{
$I->amOnPage(['site/login']);
}
public function openLoginPage(\FunctionalTester $I)
{
$I->see('Login', 'h1');
}
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 loginWithWringCredentials(\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');
}
}