You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
1.9 KiB
83 lines
1.9 KiB
<?php |
|
|
|
namespace frontend\tests\functional; |
|
|
|
use frontend\tests\_pages\SignupPage; |
|
use common\models\User; |
|
|
|
class SignupCest |
|
{ |
|
|
|
/** |
|
* This method is called after each cest class test method |
|
* @param \Codeception\Event\Test $event |
|
*/ |
|
public function _before($event) |
|
{ |
|
} |
|
|
|
/** |
|
* This method is called after each cest class test method, even if test failed. |
|
* @param \Codeception\Event\Test $event |
|
*/ |
|
public function _after($event) |
|
{ |
|
User::deleteAll([ |
|
'email' => 'tester.email@example.com', |
|
'username' => 'tester', |
|
]); |
|
} |
|
|
|
/** |
|
* This method is called when test fails. |
|
* @param \Codeception\Event\Fail $event |
|
*/ |
|
public function _fail($event) |
|
{ |
|
} |
|
|
|
/** |
|
* |
|
* @param \TestGuy $I |
|
* @param \Codeception\Scenario $scenario |
|
*/ |
|
public function testUserSignup($I, $scenario) |
|
{ |
|
$I->wantTo('ensure that signup works'); |
|
|
|
$signupPage = SignupPage::openBy($I); |
|
$I->see('Please fill out the following fields to signup:'); |
|
|
|
$I->amGoingTo('submit signup form with no data'); |
|
|
|
$signupPage->submit([]); |
|
|
|
$I->expectTo('see validation errors'); |
|
$I->see('Username cannot be blank.'); |
|
$I->see('Email cannot be blank.'); |
|
$I->see('Password cannot be blank.'); |
|
|
|
$I->amGoingTo('submit signup form with not correct email'); |
|
$signupPage->submit([ |
|
'username' => 'tester', |
|
'email' => 'tester.email', |
|
'password' => 'tester_password', |
|
]); |
|
|
|
$I->expectTo('see that email adress is wrong'); |
|
$I->dontSee('Username cannot be blank.', '.help-inline'); |
|
$I->dontSee('Password cannot be blank.', '.help-inline'); |
|
$I->see('Email is not a valid email address.', '.help-block'); |
|
|
|
$I->amGoingTo('submit signup form with correct email'); |
|
$signupPage->submit([ |
|
'username' => 'tester', |
|
'email' => 'tester.email@example.com', |
|
'password' => 'tester_password', |
|
]); |
|
|
|
$I->expectTo('see that user logged in'); |
|
$I->see('Logout (tester)'); |
|
} |
|
|
|
}
|
|
|