From a69cd2da2cedc4e87ec54130c27dffb83fbe5ead Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Fri, 15 Apr 2016 02:01:01 +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=D0=B1=D0=B0=D0=B3=20=D1=81=20=D0=B2=D0=B0=D0=BB?= =?UTF-8?q?=D0=B8=D0=B4=D0=B0=D1=82=D0=BE=D1=80=D0=BE=D0=BC=20=D0=BD=D0=B8?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=B2=20=D1=84=D0=BE=D1=80=D0=BC=D0=B5=20=D1=81?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D1=8B=20=D0=BD=D0=B8=D0=BA=D0=BD=D0=B5=D0=B9?= =?UTF-8?q?=D0=BC=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/models/ChangeUsernameForm.php | 2 +- .../functional/AccountsChangeUsernameCest.php | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/api/models/ChangeUsernameForm.php b/api/models/ChangeUsernameForm.php index 4333a07..b17095d 100644 --- a/api/models/ChangeUsernameForm.php +++ b/api/models/ChangeUsernameForm.php @@ -21,7 +21,7 @@ class ChangeUsernameForm extends PasswordProtectedForm { $account = new Account(); $account->username = $this->$attribute; if (!$account->validate(['username'])) { - $account->addErrors($account->getErrors('username')); + $this->addErrors($account->getErrors()); } } diff --git a/tests/codeception/api/functional/AccountsChangeUsernameCest.php b/tests/codeception/api/functional/AccountsChangeUsernameCest.php index e0b7805..bdc83f7 100644 --- a/tests/codeception/api/functional/AccountsChangeUsernameCest.php +++ b/tests/codeception/api/functional/AccountsChangeUsernameCest.php @@ -28,7 +28,7 @@ class AccountsChangeUsernameCest { } public function testChangeUsername(FunctionalTester $I, Scenario $scenario) { - $I->wantTo('change my password'); + $I->wantTo('change my nickname'); $I = new AccountSteps($scenario); $I->loggedInAsActiveAccount(); @@ -40,4 +40,20 @@ class AccountsChangeUsernameCest { ]); } + public function testChangeUsernameNotAvailable(FunctionalTester $I, Scenario $scenario) { + $I->wantTo('see, that nickname "in use" is not available'); + $I = new AccountSteps($scenario); + $I->loggedInAsActiveAccount(); + + $this->route->changeUsername('password_0', 'Jon'); + $I->canSeeResponseCodeIs(200); + $I->canSeeResponseIsJson(); + $I->canSeeResponseContainsJson([ + 'success' => false, + 'errors' => [ + 'username' => 'error.username_not_available', + ], + ]); + } + }