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,