From a91ce6ce8206517b2927a1aaecbadf02a17eab2a Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Sun, 17 Jul 2016 21:01:15 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=20=D1=82=D0=B5=D1=81=D1=82=20=D0=B4=D0=BB=D1=8F=20?= =?UTF-8?q?=D1=84=D0=BE=D1=80=D0=BC=D1=8B=20=D1=81=D0=BC=D0=B5=D0=BD=D1=8B?= =?UTF-8?q?=20=D0=BD=D0=B8=D0=BA=D0=B0=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=20=D1=84?= =?UTF-8?q?=D0=B8=D0=BA=D1=81=D1=82=D1=83=D1=80=20=D0=B4=D0=BB=D1=8F=20?= =?UTF-8?q?=D1=82=D0=B0=D0=B1=D0=BB=D0=B8=D1=86=D1=8B=20=D0=B8=D1=81=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=B8=D0=B8=20=D0=BD=D0=B8=D0=BA=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unit/models/profile/ChangeUsernameFormTest.php | 14 ++++---------- .../codeception/common/_support/FixtureHelper.php | 2 ++ .../common/fixtures/UsernameHistoryFixture.php | 13 +++++++++++++ .../common/fixtures/data/usernames-history.php | 4 ++++ 4 files changed, 23 insertions(+), 10 deletions(-) create mode 100644 tests/codeception/common/fixtures/UsernameHistoryFixture.php create mode 100644 tests/codeception/common/fixtures/data/usernames-history.php diff --git a/tests/codeception/api/unit/models/profile/ChangeUsernameFormTest.php b/tests/codeception/api/unit/models/profile/ChangeUsernameFormTest.php index 93c3f29..72ab52e 100644 --- a/tests/codeception/api/unit/models/profile/ChangeUsernameFormTest.php +++ b/tests/codeception/api/unit/models/profile/ChangeUsernameFormTest.php @@ -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(); }); } diff --git a/tests/codeception/common/_support/FixtureHelper.php b/tests/codeception/common/_support/FixtureHelper.php index 0bbf737..4ec7f8e 100644 --- a/tests/codeception/common/_support/FixtureHelper.php +++ b/tests/codeception/common/_support/FixtureHelper.php @@ -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', diff --git a/tests/codeception/common/fixtures/UsernameHistoryFixture.php b/tests/codeception/common/fixtures/UsernameHistoryFixture.php new file mode 100644 index 0000000..022a49d --- /dev/null +++ b/tests/codeception/common/fixtures/UsernameHistoryFixture.php @@ -0,0 +1,13 @@ +