mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Образован trait AccountFinder для поиска пользователя по его нику\мылу
Модель EmailActivation теперь умеет автоматически создавать своих правильных потомков по соответствующему типу Добавлена форма восстановления пароля и её обработчик (без контроллера)
This commit is contained in:
@@ -51,4 +51,28 @@ return [
|
||||
'created_at' => 1457890086,
|
||||
'updated_at' => 1457890086,
|
||||
],
|
||||
'account-with-fresh-forgot-password-message' => [
|
||||
'id' => 5,
|
||||
'uuid' => '4aaf4f00-3b5b-4d36-9252-9e8ee0c86679',
|
||||
'username' => 'Notch',
|
||||
'email' => 'notch@mojang.com',
|
||||
'password_hash' => '$2y$13$2rYkap5T6jG8z/mMK8a3Ou6aZxJcmAaTha6FEuujvHEmybSHRzW5e', # password_0
|
||||
'password_hash_strategy' => \common\models\Account::PASS_HASH_STRATEGY_YII2,
|
||||
'password_reset_token' => null,
|
||||
'status' => \common\models\Account::STATUS_ACTIVE,
|
||||
'created_at' => 1462891432,
|
||||
'updated_at' => 1462891432,
|
||||
],
|
||||
'account-with-expired-forgot-password-message' => [
|
||||
'id' => 6,
|
||||
'uuid' => '26187ae7-bc96-421f-9766-6517f8ee52b7',
|
||||
'username' => '23derevo',
|
||||
'email' => '23derevo@gmail.com',
|
||||
'password_hash' => '$2y$13$2rYkap5T6jG8z/mMK8a3Ou6aZxJcmAaTha6FEuujvHEmybSHRzW5e', # password_0
|
||||
'password_hash_strategy' => \common\models\Account::PASS_HASH_STRATEGY_YII2,
|
||||
'password_reset_token' => null,
|
||||
'status' => \common\models\Account::STATUS_ACTIVE,
|
||||
'created_at' => 1462891612,
|
||||
'updated_at' => 1462891612,
|
||||
],
|
||||
];
|
||||
|
@@ -1,15 +1,27 @@
|
||||
<?php
|
||||
return [
|
||||
[
|
||||
'freshRegistrationConfirmation' => [
|
||||
'key' => 'HABGCABHJ1234HBHVD',
|
||||
'account_id' => 3,
|
||||
'type' => \common\models\EmailActivation::TYPE_REGISTRATION_EMAIL_CONFIRMATION,
|
||||
'created_at' => time(),
|
||||
],
|
||||
[
|
||||
'oldRegistrationConfirmation' => [
|
||||
'key' => 'H23HBDCHHAG2HGHGHS',
|
||||
'account_id' => 4,
|
||||
'type' => \common\models\EmailActivation::TYPE_REGISTRATION_EMAIL_CONFIRMATION,
|
||||
'created_at' => time() - \api\models\RepeatAccountActivationForm::REPEAT_FREQUENCY - 10,
|
||||
'created_at' => time() - (new \common\models\confirmations\RegistrationConfirmation())->repeatTimeout - 10,
|
||||
],
|
||||
'freshPasswordRecovery' => [
|
||||
'key' => 'H24HBDCHHAG2HGHGHS',
|
||||
'account_id' => 5,
|
||||
'type' => \common\models\EmailActivation::TYPE_FORGOT_PASSWORD_KEY,
|
||||
'created_at' => time(),
|
||||
],
|
||||
'oldPasswordRecovery' => [
|
||||
'key' => 'H25HBDCHHAG2HGHGHS',
|
||||
'account_id' => 6,
|
||||
'type' => \common\models\EmailActivation::TYPE_FORGOT_PASSWORD_KEY,
|
||||
'created_at' => time() - (new \common\models\confirmations\RecoverPassword())->repeatTimeout - 10,
|
||||
],
|
||||
];
|
||||
|
34
tests/codeception/common/unit/models/EmailActivationTest.php
Normal file
34
tests/codeception/common/unit/models/EmailActivationTest.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
namespace codeception\common\unit\models;
|
||||
|
||||
use Codeception\Specify;
|
||||
use common\models\confirmations\RecoverPassword;
|
||||
use common\models\confirmations\RegistrationConfirmation;
|
||||
use common\models\EmailActivation;
|
||||
use tests\codeception\common\fixtures\EmailActivationFixture;
|
||||
use tests\codeception\console\unit\DbTestCase;
|
||||
|
||||
class EmailActivationTest extends DbTestCase {
|
||||
use Specify;
|
||||
|
||||
public function fixtures() {
|
||||
return [
|
||||
'emailActivations' => [
|
||||
'class' => EmailActivationFixture::class,
|
||||
'dataFile' => '@tests/codeception/common/fixtures/data/email-activations.php',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function testInstantiate() {
|
||||
$this->specify('return valid model type', function() {
|
||||
expect(EmailActivation::findOne([
|
||||
'type' => EmailActivation::TYPE_REGISTRATION_EMAIL_CONFIRMATION,
|
||||
]))->isInstanceOf(RegistrationConfirmation::class);
|
||||
expect(EmailActivation::findOne([
|
||||
'type' => EmailActivation::TYPE_FORGOT_PASSWORD_KEY,
|
||||
]))->isInstanceOf(RecoverPassword::class);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user