2016-05-12 03:43:19 +05:30
|
|
|
<?php
|
2019-08-01 14:47:12 +05:30
|
|
|
declare(strict_types=1);
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
namespace api\tests\unit\models\authentication;
|
2016-05-12 03:43:19 +05:30
|
|
|
|
2016-05-14 05:17:17 +05:30
|
|
|
use api\models\authentication\RecoverPasswordForm;
|
2019-02-23 04:41:57 +05:30
|
|
|
use api\tests\unit\TestCase;
|
2016-05-12 03:43:19 +05:30
|
|
|
use common\models\Account;
|
|
|
|
use common\models\EmailActivation;
|
2019-02-21 01:28:52 +05:30
|
|
|
use common\tests\fixtures\EmailActivationFixture;
|
2016-05-12 03:43:19 +05:30
|
|
|
|
2016-10-29 03:17:31 +05:30
|
|
|
class RecoverPasswordFormTest extends TestCase {
|
2016-05-12 03:43:19 +05:30
|
|
|
|
2019-05-14 04:28:29 +05:30
|
|
|
public function _fixtures(): array {
|
2016-05-12 03:43:19 +05:30
|
|
|
return [
|
2016-05-16 04:03:19 +05:30
|
|
|
'emailActivations' => EmailActivationFixture::class,
|
2016-05-12 03:43:19 +05:30
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
public function testRecoverPassword(): void {
|
2016-10-29 03:17:31 +05:30
|
|
|
$fixture = $this->tester->grabFixture('emailActivations', 'freshPasswordRecovery');
|
|
|
|
$model = new RecoverPasswordForm([
|
|
|
|
'key' => $fixture['key'],
|
|
|
|
'newPassword' => '12345678',
|
|
|
|
'newRePassword' => '12345678',
|
|
|
|
]);
|
|
|
|
$result = $model->recoverPassword();
|
2019-08-01 14:47:12 +05:30
|
|
|
$this->assertNotNull($result);
|
|
|
|
$this->assertNull($result->getRefreshToken(), 'session was not generated');
|
2016-10-29 03:17:31 +05:30
|
|
|
$this->assertFalse(EmailActivation::find()->andWhere(['key' => $fixture['key']])->exists());
|
|
|
|
/** @var Account $account */
|
|
|
|
$account = Account::findOne($fixture['account_id']);
|
|
|
|
$this->assertTrue($account->validatePassword('12345678'));
|
2016-05-12 03:43:19 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
}
|