mirror of
https://github.com/elyby/accounts.git
synced 2024-12-27 15:40:21 +05:30
Исправлен тест для формы смены ника
Добавлен класс фикстур для таблицы истории ников
This commit is contained in:
parent
681996740d
commit
a91ce6ce82
@ -7,6 +7,7 @@ use common\models\Account;
|
||||
use common\models\UsernameHistory;
|
||||
use tests\codeception\api\unit\DbTestCase;
|
||||
use tests\codeception\common\fixtures\AccountFixture;
|
||||
use tests\codeception\common\fixtures\UsernameHistoryFixture;
|
||||
|
||||
/**
|
||||
* @property AccountFixture $accounts
|
||||
@ -16,10 +17,8 @@ class ChangeUsernameFormTest extends DbTestCase {
|
||||
|
||||
public function fixtures() {
|
||||
return [
|
||||
'accounts' => [
|
||||
'class' => AccountFixture::class,
|
||||
'dataFile' => '@tests/codeception/common/fixtures/data/accounts.php',
|
||||
],
|
||||
'accounts' => AccountFixture::class,
|
||||
'history' => UsernameHistoryFixture::class,
|
||||
];
|
||||
}
|
||||
|
||||
@ -36,11 +35,6 @@ class ChangeUsernameFormTest extends DbTestCase {
|
||||
}
|
||||
|
||||
public function testChangeWithoutChange() {
|
||||
$this->markTestSkipped('This test is written invalid');
|
||||
return;
|
||||
|
||||
// TODO: этот тест написан неправильно - запись всё равно добавляется в базу данных, но тест не замечает
|
||||
/** @noinspection PhpUnreachableStatementInspection */
|
||||
$this->specify('no new UsernameHistory record, if we don\'t change nickname', function() {
|
||||
$model = $this->createModel([
|
||||
'password' => 'password_0',
|
||||
@ -51,7 +45,7 @@ class ChangeUsernameFormTest extends DbTestCase {
|
||||
expect(UsernameHistory::findOne([
|
||||
'AND',
|
||||
'username' => $this->accounts['admin']['username'],
|
||||
['>=', 'applied_in', $callTime - 5],
|
||||
['>=', 'applied_in', $callTime],
|
||||
]))->null();
|
||||
});
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ use tests\codeception\common\fixtures\EmailActivationFixture;
|
||||
use tests\codeception\common\fixtures\OauthClientFixture;
|
||||
use tests\codeception\common\fixtures\OauthScopeFixture;
|
||||
use tests\codeception\common\fixtures\OauthSessionFixture;
|
||||
use tests\codeception\common\fixtures\UsernameHistoryFixture;
|
||||
use yii\test\FixtureTrait;
|
||||
use yii\test\InitDbFixture;
|
||||
|
||||
@ -50,6 +51,7 @@ class FixtureHelper extends Module {
|
||||
'accounts' => AccountFixture::class,
|
||||
'accountSessions' => AccountSessionFixture::class,
|
||||
'emailActivations' => EmailActivationFixture::class,
|
||||
'usernamesHistory' => UsernameHistoryFixture::class,
|
||||
'oauthClients' => [
|
||||
'class' => OauthClientFixture::class,
|
||||
'dataFile' => '@tests/codeception/common/fixtures/data/oauth-clients.php',
|
||||
|
13
tests/codeception/common/fixtures/UsernameHistoryFixture.php
Normal file
13
tests/codeception/common/fixtures/UsernameHistoryFixture.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
namespace tests\codeception\common\fixtures;
|
||||
|
||||
use common\models\UsernameHistory;
|
||||
use yii\test\ActiveFixture;
|
||||
|
||||
class UsernameHistoryFixture extends ActiveFixture {
|
||||
|
||||
public $modelClass = UsernameHistory::class;
|
||||
|
||||
public $dataFile = '@tests/codeception/common/fixtures/data/usernames-history.php';
|
||||
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
<?php
|
||||
return [
|
||||
|
||||
];
|
Loading…
Reference in New Issue
Block a user