2016-05-12 03:43:19 +05:30
|
|
|
<?php
|
2019-02-21 01:28:52 +05:30
|
|
|
namespace api\tests\_support\models\authentication;
|
2016-05-12 03:43:19 +05:30
|
|
|
|
2017-09-19 22:36:16 +05:30
|
|
|
use api\components\User\AuthenticationResult;
|
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
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testRecoverPassword() {
|
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();
|
2017-09-19 22:36:16 +05:30
|
|
|
$this->assertInstanceOf(AuthenticationResult::class, $result);
|
2016-10-29 03:17:31 +05:30
|
|
|
$this->assertNull($result->getSession(), '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'));
|
2016-05-12 03:43:19 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
}
|