create project

This commit is contained in:
2024-04-24 18:02:58 +03:00
commit 17df2ce6a9
276 changed files with 15932 additions and 0 deletions

View File

@ -0,0 +1,14 @@
<?php
namespace frontend\tests\functional;
use frontend\tests\FunctionalTester;
class AboutCest
{
public function checkAbout(FunctionalTester $I)
{
$I->amOnRoute('site/about');
$I->see('About', 'h1');
}
}

View File

@ -0,0 +1,60 @@
<?php
namespace frontend\tests\functional;
use frontend\tests\FunctionalTester;
/* @var $scenario \Codeception\Scenario */
class ContactCest
{
public function _before(FunctionalTester $I)
{
$I->amOnRoute('site/contact');
}
public function checkContact(FunctionalTester $I)
{
$I->see('Contact', 'h1');
}
public function checkContactSubmitNoData(FunctionalTester $I)
{
$I->submitForm('#contact-form', []);
$I->see('Contact', 'h1');
$I->seeValidationError('Name cannot be blank');
$I->seeValidationError('Email cannot be blank');
$I->seeValidationError('Subject cannot be blank');
$I->seeValidationError('Body cannot be blank');
$I->seeValidationError('The verification code is incorrect');
}
public function checkContactSubmitNotCorrectEmail(FunctionalTester $I)
{
$I->submitForm('#contact-form', [
'ContactForm[name]' => 'tester',
'ContactForm[email]' => 'tester.email',
'ContactForm[subject]' => 'test subject',
'ContactForm[body]' => 'test content',
'ContactForm[verifyCode]' => 'testme',
]);
$I->seeValidationError('Email is not a valid email address.');
$I->dontSeeValidationError('Name cannot be blank');
$I->dontSeeValidationError('Subject cannot be blank');
$I->dontSeeValidationError('Body cannot be blank');
$I->dontSeeValidationError('The verification code is incorrect');
}
public function checkContactSubmitCorrectData(FunctionalTester $I)
{
$I->submitForm('#contact-form', [
'ContactForm[name]' => 'tester',
'ContactForm[email]' => 'tester@example.com',
'ContactForm[subject]' => 'test subject',
'ContactForm[body]' => 'test content',
'ContactForm[verifyCode]' => 'testme',
]);
$I->seeEmailIsSent();
$I->see('Thank you for contacting us. We will respond to you as soon as possible.');
}
}

View File

@ -0,0 +1,17 @@
<?php
namespace frontend\tests\functional;
use frontend\tests\FunctionalTester;
class HomeCest
{
public function checkOpen(FunctionalTester $I)
{
$I->amOnRoute(\Yii::$app->homeUrl);
$I->see('My Application');
$I->seeLink('About');
$I->click('About');
$I->see('This is the About page.');
}
}

View File

@ -0,0 +1,66 @@
<?php
namespace frontend\tests\functional;
use frontend\tests\FunctionalTester;
use common\fixtures\UserFixture;
class LoginCest
{
/**
* 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[username]' => $login,
'LoginForm[password]' => $password,
];
}
public function checkEmpty(FunctionalTester $I)
{
$I->submitForm('#login-form', $this->formParams('', ''));
$I->seeValidationError('Username 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 username or password.');
}
public function checkInactiveAccount(FunctionalTester $I)
{
$I->submitForm('#login-form', $this->formParams('test.test', 'Test1234'));
$I->seeValidationError('Incorrect username or password');
}
public function checkValidLogin(FunctionalTester $I)
{
$I->submitForm('#login-form', $this->formParams('erau', 'password_0'));
$I->see('Logout (erau)', 'form button[type=submit]');
$I->dontSeeLink('Login');
$I->dontSeeLink('Signup');
}
}

View File

@ -0,0 +1,83 @@
<?php
namespace frontend\tests\functional;
use common\fixtures\UserFixture;
use frontend\tests\FunctionalTester;
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 checkEmptyField(FunctionalTester $I)
{
$I->submitForm($this->formId, $this->formParams(''));
$I->seeValidationError('Email cannot be blank.');
}
public function checkWrongEmailFormat(FunctionalTester $I)
{
$I->submitForm($this->formId, $this->formParams('abcd.com'));
$I->seeValidationError('Email is not a valid email address.');
}
public function checkWrongEmail(FunctionalTester $I)
{
$I->submitForm($this->formId, $this->formParams('wrong@email.com'));
$I->seeValidationError('There is no user with this email address.');
}
public function checkAlreadyVerifiedEmail(FunctionalTester $I)
{
$I->submitForm($this->formId, $this->formParams('test2@mail.com'));
$I->seeValidationError('There is no user with this email address.');
}
public function checkSendSuccessfully(FunctionalTester $I)
{
$I->submitForm($this->formId, $this->formParams('test@mail.com'));
$I->canSeeEmailIsSent();
$I->seeRecord('common\models\User', [
'email' => 'test@mail.com',
'username' => 'test.test',
'status' => \common\models\User::STATUS_INACTIVE
]);
$I->see('Check your email for further instructions.');
}
}

View File

@ -0,0 +1,59 @@
<?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('Username 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[username]' => 'tester',
'SignupForm[email]' => 'ttttt',
'SignupForm[password]' => 'tester_password',
]
);
$I->dontSee('Username 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[username]' => 'tester',
'SignupForm[email]' => 'tester.email@example.com',
'SignupForm[password]' => 'tester_password',
]);
$I->seeRecord('common\models\User', [
'username' => 'tester',
'email' => 'tester.email@example.com',
'status' => \common\models\User::STATUS_INACTIVE
]);
$I->seeEmailIsSent();
$I->see('Thank you for registration. Please check your inbox for verification email.');
}
}

View File

@ -0,0 +1,68 @@
<?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 checkAlreadyActivatedToken(FunctionalTester $I)
{
$I->amOnRoute('site/verify-email', ['token' => 'already_used_token_1548675330']);
$I->canSee('Bad Request', 'h1');
$I->canSee('Wrong verify email token.');
}
public function checkSuccessVerification(FunctionalTester $I)
{
$I->amOnRoute('site/verify-email', ['token' => '4ch0qbfhvWwkcuWqjN8SWRq72SOw1KYT_1548675330']);
$I->canSee('Your email has been confirmed!');
$I->canSee('Congratulations!', 'h1');
$I->see('Logout (test.test)', 'form button[type=submit]');
$I->seeRecord('common\models\User', [
'username' => 'test.test',
'email' => 'test@mail.com',
'status' => \common\models\User::STATUS_ACTIVE
]);
}
}

View 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');
* ```
*/