Добавлено поле версии принятых правил

This commit is contained in:
ErickSkrauch
2016-08-06 18:52:03 +03:00
parent 9330041b4c
commit cf6c7bc88e
10 changed files with 90 additions and 3 deletions

View File

@@ -1,7 +1,6 @@
<?php
namespace tests\codeception\api\functional;
use Codeception\Specify;
use tests\codeception\api\_pages\AccountsRoute;
use tests\codeception\api\FunctionalTester;
@@ -30,6 +29,7 @@ class AccountsCurrentCest {
'shouldChangePassword' => false,
'isActive' => true,
'hasMojangUsernameCollision' => false,
'shouldAcceptRules' => false,
]);
$I->canSeeResponseJsonMatchesJsonPath('$.passwordChangedAt');
}

View File

@@ -8,6 +8,7 @@ use common\models\EmailActivation;
use tests\codeception\api\unit\DbTestCase;
use tests\codeception\common\fixtures\AccountFixture;
use Yii;
use const common\LATEST_RULES_VERSION;
/**
* @property array $accounts
@@ -99,6 +100,7 @@ class RegistrationFormTest extends DbTestCase {
expect('user should be valid', $account)->isInstanceOf(Account::class);
expect('password should be correct', $account->validatePassword('some_password'))->true();
expect('uuid is set', $account->uuid)->notEmpty();
expect('actual rules version is set', $account->rules_agreement_version)->equals(LATEST_RULES_VERSION);
expect('user model exists in database', Account::find()->andWhere([
'username' => 'some_username',
'email' => 'some_email@example.com',

View File

@@ -9,6 +9,7 @@ return [
'password_hash_strategy' => \common\models\Account::PASS_HASH_STRATEGY_YII2,
'lang' => 'en',
'status' => \common\models\Account::STATUS_ACTIVE,
'rules_agreement_version' => \common\LATEST_RULES_VERSION,
'created_at' => 1451775316,
'updated_at' => 1451775316,
'password_changed_at' => 1451775316,
@@ -22,6 +23,7 @@ return [
'password_hash_strategy' => \common\models\Account::PASS_HASH_STRATEGY_OLD_ELY,
'lang' => 'en',
'status' => \common\models\Account::STATUS_ACTIVE,
'rules_agreement_version' => \common\LATEST_RULES_VERSION,
'created_at' => 1385225069,
'updated_at' => 1385225069,
'password_changed_at' => 1385225069,
@@ -35,6 +37,7 @@ return [
'password_hash_strategy' => \common\models\Account::PASS_HASH_STRATEGY_YII2,
'lang' => 'en',
'status' => \common\models\Account::STATUS_REGISTERED,
'rules_agreement_version' => \common\LATEST_RULES_VERSION,
'created_at' => 1453146616,
'updated_at' => 1453146616,
'password_changed_at' => 1453146616,
@@ -48,6 +51,7 @@ return [
'password_hash_strategy' => \common\models\Account::PASS_HASH_STRATEGY_YII2,
'lang' => 'en',
'status' => \common\models\Account::STATUS_REGISTERED,
'rules_agreement_version' => \common\LATEST_RULES_VERSION,
'created_at' => 1457890086,
'updated_at' => 1457890086,
],
@@ -60,6 +64,7 @@ return [
'password_hash_strategy' => \common\models\Account::PASS_HASH_STRATEGY_YII2,
'lang' => 'en',
'status' => \common\models\Account::STATUS_ACTIVE,
'rules_agreement_version' => \common\LATEST_RULES_VERSION,
'created_at' => 1462891432,
'updated_at' => 1462891432,
],
@@ -72,6 +77,7 @@ return [
'password_hash_strategy' => \common\models\Account::PASS_HASH_STRATEGY_YII2,
'lang' => 'en',
'status' => \common\models\Account::STATUS_ACTIVE,
'rules_agreement_version' => \common\LATEST_RULES_VERSION,
'created_at' => 1462891612,
'updated_at' => 1462891612,
],
@@ -84,6 +90,7 @@ return [
'password_hash_strategy' => \common\models\Account::PASS_HASH_STRATEGY_YII2,
'lang' => 'en',
'status' => \common\models\Account::STATUS_ACTIVE,
'rules_agreement_version' => \common\LATEST_RULES_VERSION,
'created_at' => 1463427287,
'updated_at' => 1463427287,
],
@@ -96,6 +103,7 @@ return [
'password_hash_strategy' => \common\models\Account::PASS_HASH_STRATEGY_YII2,
'lang' => 'en',
'status' => \common\models\Account::STATUS_ACTIVE,
'rules_agreement_version' => \common\LATEST_RULES_VERSION,
'created_at' => 1463349615,
'updated_at' => 1463349615,
],

View File

@@ -8,6 +8,7 @@ use tests\codeception\common\fixtures\AccountFixture;
use tests\codeception\common\fixtures\MojangUsernameFixture;
use tests\codeception\common\unit\DbTestCase;
use Yii;
use const common\LATEST_RULES_VERSION;
/**
* @property array $accounts
@@ -176,4 +177,29 @@ class AccountTest extends DbTestCase {
});
}
public function testGetProfileLink() {
$model = new Account();
$model->id = '123';
$this->assertEquals('http://ely.by/u123', $model->getProfileLink());
}
public function testIsAgreedWithActualRules() {
$this->specify('get false, if rules field set in null', function() {
$model = new Account();
expect($model->isAgreedWithActualRules())->false();
});
$this->specify('get false, if rules field have version less, then actual', function() {
$model = new Account();
$model->rules_agreement_version = 0;
expect($model->isAgreedWithActualRules())->false();
});
$this->specify('get true, if rules field have equals rules version', function() {
$model = new Account();
$model->rules_agreement_version = LATEST_RULES_VERSION;
expect($model->isAgreedWithActualRules())->true();
});
}
}