mirror of
https://github.com/elyby/accounts.git
synced 2024-10-30 07:23:12 +05:30
45c2ed601d
Refactor all JWT-related components Replace RS256 with ES256 as a preferred JWT algorithm
37 lines
1.2 KiB
PHP
37 lines
1.2 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace api\tests\_support\models\authentication;
|
|
|
|
use api\models\authentication\RecoverPasswordForm;
|
|
use api\tests\unit\TestCase;
|
|
use common\models\Account;
|
|
use common\models\EmailActivation;
|
|
use common\tests\fixtures\EmailActivationFixture;
|
|
|
|
class RecoverPasswordFormTest extends TestCase {
|
|
|
|
public function _fixtures(): array {
|
|
return [
|
|
'emailActivations' => EmailActivationFixture::class,
|
|
];
|
|
}
|
|
|
|
public function testRecoverPassword() {
|
|
$fixture = $this->tester->grabFixture('emailActivations', 'freshPasswordRecovery');
|
|
$model = new RecoverPasswordForm([
|
|
'key' => $fixture['key'],
|
|
'newPassword' => '12345678',
|
|
'newRePassword' => '12345678',
|
|
]);
|
|
$result = $model->recoverPassword();
|
|
$this->assertNotNull($result);
|
|
$this->assertNull($result->getRefreshToken(), 'session was not generated');
|
|
$this->assertFalse(EmailActivation::find()->andWhere(['key' => $fixture['key']])->exists());
|
|
/** @var Account $account */
|
|
$account = Account::findOne($fixture['account_id']);
|
|
$this->assertTrue($account->validatePassword('12345678'));
|
|
}
|
|
|
|
}
|