mirror of
https://github.com/elyby/accounts.git
synced 2024-12-27 15:40:21 +05:30
Базовые модели перенесены в отдельное простраинство имён
Поправлены именования классов (хз, почему оно прежде работало)
This commit is contained in:
parent
e67257b8aa
commit
951b6928a2
@ -1,10 +1,11 @@
|
||||
<?php
|
||||
namespace api\models;
|
||||
|
||||
use api\models\base\ApiForm;
|
||||
use common\models\Account;
|
||||
use Yii;
|
||||
|
||||
class ChangePasswordForm extends BaseApiForm {
|
||||
class ChangePasswordForm extends ApiForm {
|
||||
|
||||
public $password;
|
||||
|
||||
|
@ -1,11 +1,12 @@
|
||||
<?php
|
||||
namespace api\models;
|
||||
|
||||
use api\models\base\PasswordProtectedForm;
|
||||
use common\models\Account;
|
||||
use Yii;
|
||||
use yii\helpers\ArrayHelper;
|
||||
|
||||
class ChangeUsernameForm extends BasePasswordProtectedForm {
|
||||
class ChangeUsernameForm extends PasswordProtectedForm {
|
||||
|
||||
public $username;
|
||||
|
||||
|
@ -1,12 +1,13 @@
|
||||
<?php
|
||||
namespace api\models;
|
||||
|
||||
use api\models\base\KeyConfirmationForm;
|
||||
use common\models\Account;
|
||||
use common\models\EmailActivation;
|
||||
use Yii;
|
||||
use yii\base\ErrorException;
|
||||
|
||||
class ConfirmEmailForm extends BaseKeyConfirmationForm {
|
||||
class ConfirmEmailForm extends KeyConfirmationForm {
|
||||
|
||||
public function confirm() {
|
||||
if (!$this->validate()) {
|
||||
|
@ -1,10 +1,11 @@
|
||||
<?php
|
||||
namespace api\models;
|
||||
|
||||
use api\models\base\ApiForm;
|
||||
use common\models\Account;
|
||||
use Yii;
|
||||
|
||||
class LoginForm extends BaseApiForm {
|
||||
class LoginForm extends ApiForm {
|
||||
|
||||
public $login;
|
||||
public $password;
|
||||
|
@ -2,6 +2,7 @@
|
||||
namespace api\models;
|
||||
|
||||
use api\components\ReCaptcha\Validator as ReCaptchaValidator;
|
||||
use api\models\base\ApiForm;
|
||||
use common\components\UserFriendlyRandomKey;
|
||||
use common\models\Account;
|
||||
use common\models\EmailActivation;
|
||||
@ -9,7 +10,7 @@ use Ramsey\Uuid\Uuid;
|
||||
use Yii;
|
||||
use yii\base\ErrorException;
|
||||
|
||||
class RegistrationForm extends BaseApiForm {
|
||||
class RegistrationForm extends ApiForm {
|
||||
|
||||
public $username;
|
||||
public $email;
|
||||
|
@ -1,13 +1,14 @@
|
||||
<?php
|
||||
namespace api\models;
|
||||
|
||||
use api\models\base\ApiForm;
|
||||
use common\components\UserFriendlyRandomKey;
|
||||
use common\models\Account;
|
||||
use common\models\EmailActivation;
|
||||
use Yii;
|
||||
use yii\base\ErrorException;
|
||||
|
||||
class RepeatAccountActivationForm extends BaseApiForm {
|
||||
class RepeatAccountActivationForm extends ApiForm {
|
||||
|
||||
// Частота повтора отправки нового письма
|
||||
const REPEAT_FREQUENCY = 5 * 60;
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
namespace api\models;
|
||||
namespace api\models\base;
|
||||
|
||||
use yii\base\Model;
|
||||
|
||||
class BaseApiForm extends Model {
|
||||
class ApiForm extends Model {
|
||||
|
||||
public function formName() {
|
||||
return '';
|
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
namespace api\models;
|
||||
namespace api\models\base;
|
||||
|
||||
use common\models\EmailActivation;
|
||||
|
||||
class BaseKeyConfirmationForm extends BaseApiForm {
|
||||
class KeyConfirmationForm extends ApiForm {
|
||||
|
||||
public $key;
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
namespace api\models;
|
||||
namespace api\models\base;
|
||||
|
||||
use Yii;
|
||||
|
||||
class BasePasswordProtectedForm extends BaseApiForm {
|
||||
class PasswordProtectedForm extends ApiForm {
|
||||
|
||||
public $password;
|
||||
|
@ -1,16 +1,17 @@
|
||||
<?php
|
||||
namespace tests\codeception\api\models;
|
||||
namespace tests\codeception\api\models\base;
|
||||
|
||||
use api\models\BaseApiForm;
|
||||
use api\models\base\ApiForm;
|
||||
use Codeception\Specify;
|
||||
use tests\codeception\api\unit\TestCase;
|
||||
|
||||
class BaseApiFormTest extends TestCase {
|
||||
class ApiFormTest extends TestCase {
|
||||
|
||||
use Specify;
|
||||
|
||||
public function testLoad() {
|
||||
$model = new DummyBaseApiForm();
|
||||
$this->specify('model should load data without ModelName array scope', function() use ($model) {
|
||||
$model = new DummyApiForm();
|
||||
$this->specify('model should load data without ModelName array scope', function () use ($model) {
|
||||
expect('model successful load data without prefix', $model->load(['field' => 'test-data']))->true();
|
||||
expect('field is set as passed data', $model->field)->equals('test-data');
|
||||
});
|
||||
@ -18,7 +19,7 @@ class BaseApiFormTest extends TestCase {
|
||||
|
||||
}
|
||||
|
||||
class DummyBaseApiForm extends BaseApiForm {
|
||||
class DummyApiForm extends ApiForm {
|
||||
|
||||
public $field;
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
namespace tests\codeception\api\models;
|
||||
namespace tests\codeception\api\models\base;
|
||||
|
||||
use api\models\BasePasswordProtectedForm;
|
||||
use api\models\base\PasswordProtectedForm;
|
||||
use Codeception\Specify;
|
||||
use common\models\Account;
|
||||
use tests\codeception\api\unit\TestCase;
|
||||
|
||||
class BasePasswordProtectedFormTest extends TestCase {
|
||||
class PasswordProtectedFormTest extends TestCase {
|
||||
use Specify;
|
||||
|
||||
public function testValidatePassword() {
|
||||
@ -27,7 +27,7 @@ class BasePasswordProtectedFormTest extends TestCase {
|
||||
|
||||
}
|
||||
|
||||
class DummyBasePasswordProtectedForm extends BasePasswordProtectedForm {
|
||||
class DummyBasePasswordProtectedForm extends PasswordProtectedForm {
|
||||
|
||||
protected function getAccount() {
|
||||
return new Account([
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace tests\codeception\api\models;
|
||||
namespace tests\codeception\api\models\base;
|
||||
|
||||
use api\models\BaseKeyConfirmationForm;
|
||||
use api\models\base\KeyConfirmationForm;
|
||||
use Codeception\Specify;
|
||||
use tests\codeception\api\unit\DbTestCase;
|
||||
use tests\codeception\common\fixtures\EmailActivationFixture;
|
||||
@ -10,7 +10,7 @@ use Yii;
|
||||
/**
|
||||
* @property array $emailActivations
|
||||
*/
|
||||
class BaseKeyConfirmationFormTest extends DbTestCase {
|
||||
class KeyConfirmationFormTest extends DbTestCase {
|
||||
use Specify;
|
||||
|
||||
public function fixtures() {
|
||||
@ -23,7 +23,7 @@ class BaseKeyConfirmationFormTest extends DbTestCase {
|
||||
}
|
||||
|
||||
protected function createModel($key = null) {
|
||||
return new BaseKeyConfirmationForm([
|
||||
return new KeyConfirmationForm([
|
||||
'key' => $key,
|
||||
]);
|
||||
}
|
Loading…
Reference in New Issue
Block a user