Initial commit
This commit is contained in:
67
frontend/tests/functional/LoginCest.php
Normal file
67
frontend/tests/functional/LoginCest.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\tests\functional;
|
||||
|
||||
use frontend\tests\FunctionalTester;
|
||||
use common\fixtures\UserFixture;
|
||||
|
||||
class LoginCest
|
||||
{
|
||||
protected $formId = '#login-form';
|
||||
/**
|
||||
* Load fixtures before db transaction begin
|
||||
* Called in _before()
|
||||
* @see \Codeception\Module\Yii2::_before()
|
||||
* @see \Codeception\Module\Yii2::loadFixtures()
|
||||
* @return array
|
||||
*/
|
||||
public function _fixtures()
|
||||
{
|
||||
return [
|
||||
'user' => [
|
||||
'class' => UserFixture::class,
|
||||
'dataFile' => codecept_data_dir() . 'login_data.php',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function _before(FunctionalTester $I)
|
||||
{
|
||||
$I->amOnRoute('site/login');
|
||||
}
|
||||
|
||||
protected function formParams($login, $password)
|
||||
{
|
||||
return [
|
||||
'LoginForm[email]' => $login,
|
||||
'LoginForm[password]' => $password,
|
||||
];
|
||||
}
|
||||
|
||||
public function checkEmpty(FunctionalTester $I)
|
||||
{
|
||||
$I->submitForm($this->formId, $this->formParams('', ''));
|
||||
$I->seeValidationError('Email cannot be blank.');
|
||||
$I->seeValidationError('Password cannot be blank.');
|
||||
}
|
||||
|
||||
public function checkWrongPassword(FunctionalTester $I)
|
||||
{
|
||||
$I->submitForm('#login-form', $this->formParams('admin', 'wrong'));
|
||||
$I->seeValidationError('Incorrect email or password.');
|
||||
}
|
||||
|
||||
public function checkInactiveAccount(FunctionalTester $I)
|
||||
{
|
||||
$I->submitForm($this->formId, $this->formParams('test@mail.com', 'Test1234'));
|
||||
$I->seeValidationError('Incorrect email or password');
|
||||
}
|
||||
|
||||
public function checkValidLogin(FunctionalTester $I)
|
||||
{
|
||||
$I->submitForm($this->formId, $this->formParams('sfriesen@jenkins.info', 'password_0'));
|
||||
$I->see('Logout (sfriesen@jenkins.info)', 'form button[type=submit]');
|
||||
$I->dontSeeLink('Login');
|
||||
$I->dontSeeLink('Signup');
|
||||
}
|
||||
}
|
||||
53
frontend/tests/functional/ResendVerificationEmailCest.php
Normal file
53
frontend/tests/functional/ResendVerificationEmailCest.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\tests\functional;
|
||||
|
||||
use frontend\tests\FunctionalTester;
|
||||
use common\fixtures\UserFixture;
|
||||
|
||||
class ResendVerificationEmailCest
|
||||
{
|
||||
protected $formId = '#resend-verification-email-form';
|
||||
|
||||
|
||||
/**
|
||||
* Load fixtures before db transaction begin
|
||||
* Called in _before()
|
||||
* @see \Codeception\Module\Yii2::_before()
|
||||
* @see \Codeception\Module\Yii2::loadFixtures()
|
||||
* @return array
|
||||
*/
|
||||
public function _fixtures()
|
||||
{
|
||||
return [
|
||||
'user' => [
|
||||
'class' => UserFixture::class,
|
||||
'dataFile' => codecept_data_dir() . 'user.php',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function _before(FunctionalTester $I)
|
||||
{
|
||||
$I->amOnRoute('site/resend-verification-email');
|
||||
}
|
||||
|
||||
protected function formParams($email)
|
||||
{
|
||||
return [
|
||||
'ResendVerificationEmailForm[email]' => $email
|
||||
];
|
||||
}
|
||||
|
||||
public function checkPage(FunctionalTester $I)
|
||||
{
|
||||
$I->see('Resend verification email', 'h1');
|
||||
$I->see('Please fill out your email. A verification email will be sent there.');
|
||||
}
|
||||
|
||||
public function checkSendSuccessfully(FunctionalTester $I)
|
||||
{
|
||||
$I->submitForm($this->formId, $this->formParams('test@mail.com'));
|
||||
$I->see('Check your email for further instructions.');
|
||||
}
|
||||
}
|
||||
57
frontend/tests/functional/SignupCest.php
Normal file
57
frontend/tests/functional/SignupCest.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\tests\functional;
|
||||
|
||||
use frontend\tests\FunctionalTester;
|
||||
|
||||
class SignupCest
|
||||
{
|
||||
protected $formId = '#form-signup';
|
||||
|
||||
|
||||
public function _before(FunctionalTester $I)
|
||||
{
|
||||
$I->amOnRoute('site/signup');
|
||||
}
|
||||
|
||||
public function signupWithEmptyFields(FunctionalTester $I)
|
||||
{
|
||||
$I->see('Signup', 'h1');
|
||||
$I->see('Please fill out the following fields to signup:');
|
||||
$I->submitForm($this->formId, []);
|
||||
$I->seeValidationError('First Name cannot be blank.');
|
||||
$I->seeValidationError('Email cannot be blank.');
|
||||
$I->seeValidationError('Password cannot be blank.');
|
||||
}
|
||||
|
||||
public function signupWithWrongEmail(FunctionalTester $I)
|
||||
{
|
||||
$I->submitForm(
|
||||
$this->formId, [
|
||||
'SignupForm[first_name]' => 'tester',
|
||||
'SignupForm[email]' => 'ttttt',
|
||||
'SignupForm[password]' => 'tester_password',
|
||||
]
|
||||
);
|
||||
$I->dontSee('First Name cannot be blank.', '.invalid-feedback');
|
||||
$I->dontSee('Password cannot be blank.', '.invalid-feedback');
|
||||
$I->see('Email is not a valid email address.', '.invalid-feedback');
|
||||
}
|
||||
|
||||
public function signupSuccessfully(FunctionalTester $I)
|
||||
{
|
||||
$I->submitForm($this->formId, [
|
||||
'SignupForm[first_name]' => 'tester',
|
||||
'SignupForm[email]' => 'tester.email@example.com',
|
||||
'SignupForm[password]' => 'tester_password',
|
||||
]);
|
||||
|
||||
$I->seeRecord('common\models\User', [
|
||||
'first_name' => 'tester',
|
||||
'email' => 'tester.email@example.com',
|
||||
'status' => \common\models\User::STATUS_UNVERIFIED
|
||||
]);
|
||||
|
||||
$I->see('Thank you for registration. Please check your email for further instructions');
|
||||
}
|
||||
}
|
||||
59
frontend/tests/functional/VerifyEmailCest.php
Normal file
59
frontend/tests/functional/VerifyEmailCest.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\tests\functional;
|
||||
|
||||
use common\fixtures\UserFixture;
|
||||
use frontend\tests\FunctionalTester;
|
||||
|
||||
class VerifyEmailCest
|
||||
{
|
||||
/**
|
||||
* Load fixtures before db transaction begin
|
||||
* Called in _before()
|
||||
* @see \Codeception\Module\Yii2::_before()
|
||||
* @see \Codeception\Module\Yii2::loadFixtures()
|
||||
* @return array
|
||||
*/
|
||||
public function _fixtures()
|
||||
{
|
||||
return [
|
||||
'user' => [
|
||||
'class' => UserFixture::class,
|
||||
'dataFile' => codecept_data_dir() . 'user.php',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function checkEmptyToken(FunctionalTester $I)
|
||||
{
|
||||
$I->amOnRoute('site/verify-email', ['token' => '']);
|
||||
$I->canSee('Bad Request', 'h1');
|
||||
$I->canSee('Verify email token cannot be blank.');
|
||||
}
|
||||
|
||||
public function checkInvalidToken(FunctionalTester $I)
|
||||
{
|
||||
$I->amOnRoute('site/verify-email', ['token' => 'wrong_token']);
|
||||
$I->canSee('Bad Request', 'h1');
|
||||
$I->canSee('Wrong verify email token.');
|
||||
}
|
||||
|
||||
public function checkNoToken(FunctionalTester $I)
|
||||
{
|
||||
$I->amOnRoute('site/verify-email');
|
||||
$I->canSee('Bad Request', 'h1');
|
||||
$I->canSee('Missing required parameters: token');
|
||||
}
|
||||
|
||||
public function checkSuccessVerification(FunctionalTester $I)
|
||||
{
|
||||
$I->amOnRoute('site/verify-email', ['token' => '4ch0qbfhvWwkcuWqjN8SWRq72SOw1KYT_1548675330']);
|
||||
$I->canSee('Your email has been confirmed! Upon our approval you will receive a welcome email.');
|
||||
$I->canSee('Sales Agent Portal', 'h1');
|
||||
|
||||
$I->seeRecord('common\models\User', [
|
||||
'email' => 'test@mail.com',
|
||||
'status' => \common\models\User::STATUS_VERIFIED
|
||||
]);
|
||||
}
|
||||
}
|
||||
16
frontend/tests/functional/_bootstrap.php
Normal file
16
frontend/tests/functional/_bootstrap.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/**
|
||||
* Here you can initialize variables via \Codeception\Util\Fixtures class
|
||||
* to store data in global array and use it in Cests.
|
||||
*
|
||||
* ```php
|
||||
* // Here _bootstrap.php
|
||||
* \Codeception\Util\Fixtures::add('user1', ['name' => 'davert']);
|
||||
* ```
|
||||
*
|
||||
* In Cests
|
||||
*
|
||||
* ```php
|
||||
* \Codeception\Util\Fixtures::get('user1');
|
||||
* ```
|
||||
*/
|
||||
Reference in New Issue
Block a user