2016-01-21 02:44:29 +05:30
|
|
|
<?php
|
2019-08-01 14:47:12 +05:30
|
|
|
declare(strict_types=1);
|
|
|
|
|
2019-02-21 01:28:52 +05:30
|
|
|
namespace api\tests\_support\models\authentication;
|
2016-01-21 02:44:29 +05:30
|
|
|
|
2016-05-14 05:17:17 +05:30
|
|
|
use api\models\authentication\ConfirmEmailForm;
|
2019-02-23 04:41:57 +05:30
|
|
|
use api\tests\unit\TestCase;
|
2016-01-21 02:44:29 +05:30
|
|
|
use common\models\Account;
|
|
|
|
use common\models\EmailActivation;
|
2019-02-21 01:28:52 +05:30
|
|
|
use common\tests\fixtures\EmailActivationFixture;
|
2016-01-21 02:44:29 +05:30
|
|
|
|
2016-10-29 03:17:31 +05:30
|
|
|
class ConfirmEmailFormTest extends TestCase {
|
2016-01-21 02:44:29 +05:30
|
|
|
|
2019-05-14 04:28:29 +05:30
|
|
|
public function _fixtures(): array {
|
2016-01-21 02:44:29 +05:30
|
|
|
return [
|
2016-05-16 04:03:19 +05:30
|
|
|
'emailActivations' => EmailActivationFixture::class,
|
2016-01-21 02:44:29 +05:30
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2016-10-29 03:17:31 +05:30
|
|
|
public function testConfirm() {
|
|
|
|
$fixture = $this->tester->grabFixture('emailActivations', 'freshRegistrationConfirmation');
|
|
|
|
$model = $this->createModel($fixture['key']);
|
|
|
|
$result = $model->confirm();
|
2019-08-01 14:47:12 +05:30
|
|
|
$this->assertNotNull($result);
|
|
|
|
$this->assertNotNull($result->getRefreshToken(), 'session was generated');
|
2016-10-29 03:17:31 +05:30
|
|
|
$activationExists = EmailActivation::find()->andWhere(['key' => $fixture['key']])->exists();
|
|
|
|
$this->assertFalse($activationExists, 'email activation key is not exist');
|
2016-12-04 22:26:49 +05:30
|
|
|
/** @var Account $account */
|
|
|
|
$account = Account::findOne($fixture['account_id']);
|
2019-02-26 04:56:02 +05:30
|
|
|
$this->assertSame(Account::STATUS_ACTIVE, $account->status, 'user status changed to active');
|
2016-10-29 03:17:31 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
private function createModel($key) {
|
2016-01-21 02:44:29 +05:30
|
|
|
return new ConfirmEmailForm([
|
|
|
|
'key' => $key,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|