accounts/tests/codeception/api/unit/models/authentication/ConfirmEmailFormTest.php
ErickSkrauch 50439fdaeb Реализованы формы для шагов смены E-mail адреса, покрыты unit-тестами
У EmailActivation добавлено поле $_data и дописано поведение для работы с ним
Упрощено подключение фикстур для EmailActivations
2016-05-16 01:33:19 +03:00

44 lines
1.4 KiB
PHP

<?php
namespace tests\codeception\api\models\authentication;
use api\models\authentication\ConfirmEmailForm;
use Codeception\Specify;
use common\models\Account;
use common\models\EmailActivation;
use tests\codeception\api\unit\DbTestCase;
use tests\codeception\common\fixtures\EmailActivationFixture;
use Yii;
/**
* @property EmailActivationFixture $emailActivations
*/
class ConfirmEmailFormTest extends DbTestCase {
use Specify;
public function fixtures() {
return [
'emailActivations' => EmailActivationFixture::class,
];
}
protected function createModel($key) {
return new ConfirmEmailForm([
'key' => $key,
]);
}
public function testConfirm() {
$fixture = $this->emailActivations['freshRegistrationConfirmation'];
$model = $this->createModel($fixture['key']);
$this->specify('expect true result', function() use ($model, $fixture) {
expect('model return successful result', $model->confirm())->notEquals(false);
$activationExists = EmailActivation::find()->andWhere(['key' => $fixture['key']])->exists();
expect('email activation key is not exist', $activationExists)->false();
/** @var Account $user */
$user = Account::findOne($fixture['account_id']);
expect('user status changed to active', $user->status)->equals(Account::STATUS_ACTIVE);
});
}
}