mirror of
https://github.com/elyby/accounts.git
synced 2026-04-25 00:32:35 +05:30
В проект внедрён RabbitMQ.
Контроллер для работы с RabbitMQ научился создавать типизированные аргументы для $body Добавлена таблица с историей ников Добавлена таблица Mojang ников Добавлена проверка активированности аккаунта в AccountsController
This commit is contained in:
@@ -13,3 +13,4 @@ $_SERVER['SERVER_NAME'] = 'localhost';
|
||||
$_SERVER['SERVER_PORT'] = '80';
|
||||
|
||||
Yii::setAlias('@tests', dirname(dirname(__DIR__)));
|
||||
\Codeception\Specify\Config::setDeepClone(false);
|
||||
|
||||
11
tests/codeception/common/fixtures/MojangUsernameFixture.php
Normal file
11
tests/codeception/common/fixtures/MojangUsernameFixture.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
namespace tests\codeception\common\fixtures;
|
||||
|
||||
use common\models\MojangUsername;
|
||||
use yii\test\ActiveFixture;
|
||||
|
||||
class MojangUsernameFixture extends ActiveFixture {
|
||||
|
||||
public $modelClass = MojangUsername::class;
|
||||
|
||||
}
|
||||
23
tests/codeception/common/fixtures/data/mojang-usernames.php
Normal file
23
tests/codeception/common/fixtures/data/mojang-usernames.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
return [
|
||||
'ErickSkrauch' => [
|
||||
'username' => 'ErickSkrauch',
|
||||
'uuid' => '3e3ee6c35afa48abb61e8cd8c42fc0d9',
|
||||
'last_pulled_at' => 1461429129,
|
||||
],
|
||||
'Notch' => [
|
||||
'username' => 'Notch',
|
||||
'uuid' => '069a79f444e94726a5befca90e38aaf5',
|
||||
'last_pulled_at' => 1461429207,
|
||||
],
|
||||
'not-exists' => [
|
||||
'username' => '100_not_exists',
|
||||
'uuid' => 'f8d4ac1fb24d423483d619832b5d475c',
|
||||
'last_pulled_at' => 1461433981,
|
||||
],
|
||||
'uuid-changed' => [
|
||||
'username' => 'jeb',
|
||||
'uuid' => 'ef4c8352cecc417bbcae32f1f3e2828b',
|
||||
'last_pulled_at' => 1461434315,
|
||||
],
|
||||
];
|
||||
@@ -5,11 +5,13 @@ use Codeception\Specify;
|
||||
use common\components\UserPass;
|
||||
use common\models\Account;
|
||||
use tests\codeception\common\fixtures\AccountFixture;
|
||||
use tests\codeception\common\fixtures\MojangUsernameFixture;
|
||||
use tests\codeception\common\unit\DbTestCase;
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* @property array $accounts
|
||||
* @property array $mojangAccounts
|
||||
*/
|
||||
class AccountTest extends DbTestCase {
|
||||
use Specify;
|
||||
@@ -20,6 +22,10 @@ class AccountTest extends DbTestCase {
|
||||
'class' => AccountFixture::class,
|
||||
'dataFile' => '@tests/codeception/common/fixtures/data/accounts.php',
|
||||
],
|
||||
'mojangAccounts' => [
|
||||
'class' => MojangUsernameFixture::class,
|
||||
'dataFile' => '@tests/codeception/common/fixtures/data/mojang-usernames.php',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -73,6 +79,7 @@ class AccountTest extends DbTestCase {
|
||||
}
|
||||
|
||||
public function testValidateEmail() {
|
||||
// TODO: пропускать этот тест, если падает ошибка с недостпуностью интернет соединения
|
||||
$this->specify('email required', function() {
|
||||
$model = new Account(['email' => null]);
|
||||
expect($model->validate(['email']))->false();
|
||||
@@ -149,4 +156,18 @@ class AccountTest extends DbTestCase {
|
||||
});
|
||||
}
|
||||
|
||||
public function testHasMojangUsernameCollision() {
|
||||
$this->specify('Expect true if collision with current username', function() {
|
||||
$model = new Account();
|
||||
$model->username = 'ErickSkrauch';
|
||||
expect($model->hasMojangUsernameCollision())->true();
|
||||
});
|
||||
|
||||
$this->specify('Expect false if some rare username without any collision on Mojang', function() {
|
||||
$model = new Account();
|
||||
$model->username = 'rare-username';
|
||||
expect($model->hasMojangUsernameCollision())->false();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user