mirror of
https://github.com/elyby/accounts.git
synced 2024-11-19 19:53:08 +05:30
91 lines
2.5 KiB
PHP
91 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace tests\codeception\api\functional;
|
|
|
|
use tests\codeception\api\_pages\SignupPage;
|
|
use common\models\Account;
|
|
|
|
class SignupCest
|
|
{
|
|
|
|
/**
|
|
* This method is called before each cest class test method
|
|
* @param \Codeception\Event\TestEvent $event
|
|
*/
|
|
public function _before($event)
|
|
{
|
|
}
|
|
|
|
/**
|
|
* This method is called after each cest class test method, even if test failed.
|
|
* @param \Codeception\Event\TestEvent $event
|
|
*/
|
|
public function _after($event)
|
|
{
|
|
Account::deleteAll([
|
|
'email' => 'tester.email@example.com',
|
|
'username' => 'tester',
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* This method is called when test fails.
|
|
* @param \Codeception\Event\FailEvent $event
|
|
*/
|
|
public function _fail($event)
|
|
{
|
|
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param \codeception_api\FunctionalTester $I
|
|
* @param \Codeception\Scenario $scenario
|
|
*/
|
|
public function testUserSignup($I, $scenario)
|
|
{
|
|
$I->wantTo('ensure that signup works');
|
|
|
|
$signupPage = SignupPage::openBy($I);
|
|
$I->see('Signup', 'h1');
|
|
$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.', '.help-block');
|
|
$I->see('Email cannot be blank.', '.help-block');
|
|
$I->see('Password cannot be blank.', '.help-block');
|
|
|
|
$I->amGoingTo('submit signup form with not correct email');
|
|
$signupPage->submit([
|
|
'username' => 'tester',
|
|
'email' => 'tester.email',
|
|
'password' => 'tester_password',
|
|
]);
|
|
|
|
$I->expectTo('see that email address is wrong');
|
|
$I->dontSee('Username cannot be blank.', '.help-block');
|
|
$I->dontSee('Password cannot be blank.', '.help-block');
|
|
$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 is created');
|
|
$I->seeRecord('common\models\User', [
|
|
'username' => 'tester',
|
|
'email' => 'tester.email@example.com',
|
|
]);
|
|
|
|
$I->expectTo('see that user logged in');
|
|
$I->seeLink('Logout (tester)');
|
|
}
|
|
}
|