From 6c74e231570c59445f516d5df526bf29f452f82e Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Mon, 16 May 2016 23:09:44 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=BF=D0=B8=D1=81=D0=B0=D0=BD?= =?UTF-8?q?=D1=8B=20=D0=BD=D0=B5=D0=B4=D0=BE=D1=81=D1=82=D0=B0=D1=8E=D1=89?= =?UTF-8?q?=D0=B8=D0=B5=20=D1=82=D0=B5=D1=81=D1=82=D1=8B=20=D0=B4=D0=BB?= =?UTF-8?q?=D1=8F=20=D1=84=D0=BE=D1=80=D0=BC=20=D1=81=D0=BC=D0=B5=D0=BD?= =?UTF-8?q?=D1=8B=20E-mail=20=D0=B0=D0=B4=D1=80=D0=B5=D1=81=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../codeception/api/_pages/AccountsRoute.php | 15 ++++++++ ...AccountsChangeEmailConfirmNewEmailCest.php | 34 +++++++++++++++++++ .../AccountsChangeEmailSubmitNewEmailCest.php | 31 +++++++++++++++++ .../common/fixtures/data/accounts.php | 14 +++++++- .../fixtures/data/email-activations.php | 8 ++++- 5 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 tests/codeception/api/functional/AccountsChangeEmailConfirmNewEmailCest.php create mode 100644 tests/codeception/api/functional/AccountsChangeEmailSubmitNewEmailCest.php diff --git a/tests/codeception/api/_pages/AccountsRoute.php b/tests/codeception/api/_pages/AccountsRoute.php index 7dd1609..2e8232e 100644 --- a/tests/codeception/api/_pages/AccountsRoute.php +++ b/tests/codeception/api/_pages/AccountsRoute.php @@ -35,4 +35,19 @@ class AccountsRoute extends BasePage { $this->actor->sendPOST($this->getUrl()); } + public function changeEmailSubmitNewEmail($key = null, $email = null) { + $this->route = ['accounts/change-email-submit-new-email']; + $this->actor->sendPOST($this->getUrl(), [ + 'key' => $key, + 'email' => $email, + ]); + } + + public function changeEmailConfirmNewEmail($key = null) { + $this->route = ['accounts/change-email-confirm-new-email']; + $this->actor->sendPOST($this->getUrl(), [ + 'key' => $key, + ]); + } + } diff --git a/tests/codeception/api/functional/AccountsChangeEmailConfirmNewEmailCest.php b/tests/codeception/api/functional/AccountsChangeEmailConfirmNewEmailCest.php new file mode 100644 index 0000000..40fd8eb --- /dev/null +++ b/tests/codeception/api/functional/AccountsChangeEmailConfirmNewEmailCest.php @@ -0,0 +1,34 @@ +route = new AccountsRoute($I); + } + + public function testConfirmNewEmail(FunctionalTester $I) { + $I->wantTo('change my email and get changed value'); + $I->loggedInAsActiveAccount('CrafterGameplays', 'password_0'); + + $this->route->changeEmailConfirmNewEmail('H28HBDCHHAG2HGHGHS'); + $I->canSeeResponseCodeIs(200); + $I->canSeeResponseIsJson(); + $I->canSeeResponseContainsJson([ + 'success' => true, + 'data' => [ + 'email' => 'my-new-email@ely.by', + ], + ]); + } + +} diff --git a/tests/codeception/api/functional/AccountsChangeEmailSubmitNewEmailCest.php b/tests/codeception/api/functional/AccountsChangeEmailSubmitNewEmailCest.php new file mode 100644 index 0000000..f70ac36 --- /dev/null +++ b/tests/codeception/api/functional/AccountsChangeEmailSubmitNewEmailCest.php @@ -0,0 +1,31 @@ +route = new AccountsRoute($I); + } + + public function testSubmitNewEmail(FunctionalTester $I) { + $I->wantTo('submit new email'); + $I->loggedInAsActiveAccount('ILLIMUNATI', 'password_0'); + + $this->route->changeEmailSubmitNewEmail('H27HBDCHHAG2HGHGHS', 'my-new-email@ely.by'); + $I->canSeeResponseCodeIs(200); + $I->canSeeResponseIsJson(); + $I->canSeeResponseContainsJson([ + 'success' => true, + ]); + } + +} diff --git a/tests/codeception/common/fixtures/data/accounts.php b/tests/codeception/common/fixtures/data/accounts.php index 9919b88..28dc423 100644 --- a/tests/codeception/common/fixtures/data/accounts.php +++ b/tests/codeception/common/fixtures/data/accounts.php @@ -75,8 +75,20 @@ return [ 'created_at' => 1462891612, 'updated_at' => 1462891612, ], - 'account-with-change-email-finish-state' => [ + 'account-with-change-email-init-state' => [ 'id' => 7, + 'uuid' => '7d728533-847a-4661-9bc7-3df01b2282ef', + 'username' => 'ILLIMUNATI', + 'email' => 'illuminati@gmail.com', + 'password_hash' => '$2y$13$2rYkap5T6jG8z/mMK8a3Ou6aZxJcmAaTha6FEuujvHEmybSHRzW5e', # password_0 + 'password_hash_strategy' => \common\models\Account::PASS_HASH_STRATEGY_YII2, + 'lang' => 'en', + 'status' => \common\models\Account::STATUS_ACTIVE, + 'created_at' => 1463427287, + 'updated_at' => 1463427287, + ], + 'account-with-change-email-finish-state' => [ + 'id' => 8, 'uuid' => '4c34f2cc-4bd9-454b-9583-bb52f020ec16', 'username' => 'CrafterGameplays', 'email' => 'crafter@gmail.com', diff --git a/tests/codeception/common/fixtures/data/email-activations.php b/tests/codeception/common/fixtures/data/email-activations.php index 17083a7..48cd1e0 100644 --- a/tests/codeception/common/fixtures/data/email-activations.php +++ b/tests/codeception/common/fixtures/data/email-activations.php @@ -30,9 +30,15 @@ return [ 'type' => \common\models\EmailActivation::TYPE_CURRENT_EMAIL_CONFIRMATION, 'created_at' => time() - 10, ], - 'newEmailConfirmation' => [ + 'currentChangeEmailConfirmation' => [ 'key' => 'H27HBDCHHAG2HGHGHS', 'account_id' => 7, + 'type' => \common\models\EmailActivation::TYPE_CURRENT_EMAIL_CONFIRMATION, + 'created_at' => time() - 10, + ], + 'newEmailConfirmation' => [ + 'key' => 'H28HBDCHHAG2HGHGHS', + 'account_id' => 8, 'type' => \common\models\EmailActivation::TYPE_NEW_EMAIL_CONFIRMATION, '_data' => serialize(['newEmail' => 'my-new-email@ely.by']), 'created_at' => time() - 10,