mirror of
https://github.com/elyby/accounts.git
synced 2024-12-26 07:09:46 +05:30
7e90f1838e
Реализована форма подтверждения email, обмазана тестами Слегка отрефакторена форма регистрации и авторизации в пользу выноса части логики в общего родителя Проект зачищен от стандартных тестовых параметров Пофикшены методы доступа к API
63 lines
2.0 KiB
PHP
63 lines
2.0 KiB
PHP
<?php
|
|
namespace tests\codeception\api\models;
|
|
|
|
use api\models\BaseKeyConfirmationForm;
|
|
use Codeception\Specify;
|
|
use tests\codeception\api\unit\DbTestCase;
|
|
use tests\codeception\common\fixtures\EmailActivationFixture;
|
|
use Yii;
|
|
|
|
/**
|
|
* @property array $emailActivations
|
|
*/
|
|
class BaseKeyConfirmationFormTest extends DbTestCase {
|
|
use Specify;
|
|
|
|
public function fixtures() {
|
|
return [
|
|
'emailActivations' => [
|
|
'class' => EmailActivationFixture::class,
|
|
'dataFile' => '@tests/codeception/common/fixtures/data/email-activations.php',
|
|
],
|
|
];
|
|
}
|
|
|
|
protected function createModel($key = null) {
|
|
return new BaseKeyConfirmationForm([
|
|
'key' => $key,
|
|
]);
|
|
}
|
|
|
|
public function testEmptyKey() {
|
|
$model = $this->createModel();
|
|
$this->specify('get error.key_is_required with validating empty key field', function () use ($model) {
|
|
expect('model should don\'t pass validation', $model->validate())->false();
|
|
expect('error messages should be set', $model->errors)->equals([
|
|
'key' => [
|
|
'error.key_is_required',
|
|
],
|
|
]);
|
|
});
|
|
}
|
|
|
|
public function testIncorrectKey() {
|
|
$model = $this->createModel('not-exists-key');
|
|
$this->specify('get error.key_not_exists with validation wrong key', function () use ($model) {
|
|
expect('model should don\'t pass validation', $model->validate())->false();
|
|
expect('error messages should be set', $model->errors)->equals([
|
|
'key' => [
|
|
'error.key_not_exists',
|
|
],
|
|
]);
|
|
});
|
|
}
|
|
|
|
public function testCorrectKey() {
|
|
$model = $this->createModel($this->emailActivations[0]['key']);
|
|
$this->specify('no errors if key exists', function () use ($model) {
|
|
expect('model should pass validation', $model->validate())->true();
|
|
});
|
|
}
|
|
|
|
}
|