Мигрирована логика блокировки аккаунтов

This commit is contained in:
ErickSkrauch
2016-08-22 00:09:14 +03:00
parent b57b015f66
commit 72a7f743be
5 changed files with 22 additions and 7 deletions

View File

@ -18,7 +18,13 @@ class ActiveUserRuleTest extends TestCase {
$account = new AccountIdentity();
$this->specify('get false if user not finished registration', function() use (&$account) {
$account->status = 0;
$account->status = Account::STATUS_REGISTERED;
$filter = $this->getFilterMock($account);
expect($this->callProtected($filter, 'matchCustom', new Action(null, null)))->false();
});
$this->specify('get false if user has banned status', function() use (&$account) {
$account->status = Account::STATUS_BANNED;
$filter = $this->getFilterMock($account);
expect($this->callProtected($filter, 'matchCustom', new Action(null, null)))->false();
});

View File

@ -8,7 +8,6 @@ use Codeception\Specify;
use common\models\Account;
use tests\codeception\api\unit\DbTestCase;
use tests\codeception\common\fixtures\AccountFixture;
use Yii;
/**
* @property AccountFixture $accounts
@ -84,6 +83,14 @@ class LoginFormTest extends DbTestCase {
expect($model->getErrors('login'))->equals(['error.account_not_activated']);
});
$this->specify('error.account_banned if account has banned status', function () {
$model = $this->createModel([
'account' => new AccountIdentity(['status' => Account::STATUS_BANNED]),
]);
$model->validateActivity('login');
expect($model->getErrors('login'))->equals(['error.account_banned']);
});
$this->specify('no errors if account active', function () {
$model = $this->createModel([
'account' => new AccountIdentity(['status' => Account::STATUS_ACTIVE]),