Удалена зависимость от yiisoft/yii2-codeception в пользу интегрированного в Codeception генератора REST адресов

Реорганизованы объекты Pages для Functional тестов
Исправлены не переименованные тесты, оставшиеся после последнего рефакторинга
This commit is contained in:
ErickSkrauch
2017-10-01 03:24:23 +03:00
parent f51bfcb20d
commit 0dbbb2e0de
20 changed files with 101 additions and 205 deletions

View File

@@ -26,7 +26,6 @@
"webmozart/assert": "^1.2.0" "webmozart/assert": "^1.2.0"
}, },
"require-dev": { "require-dev": {
"yiisoft/yii2-codeception": "*",
"yiisoft/yii2-debug": "*", "yiisoft/yii2-debug": "*",
"yiisoft/yii2-faker": "*", "yiisoft/yii2-faker": "*",
"flow/jsonpath": "^0.3.1", "flow/jsonpath": "^0.3.1",

View File

@@ -1,21 +1,14 @@
<?php <?php
namespace tests\codeception\api\_pages; namespace tests\codeception\api\_pages;
use yii\codeception\BasePage;
/**
* @property \tests\codeception\api\FunctionalTester $actor
*/
class AccountsRoute extends BasePage { class AccountsRoute extends BasePage {
public function get(int $accountId) { public function get(int $accountId) {
$this->route = "/v1/accounts/{$accountId}"; $this->getActor()->sendGET("/v1/accounts/{$accountId}");
$this->actor->sendGET($this->getUrl());
} }
public function changePassword(int $accountId, $currentPassword = null, $newPassword = null, $newRePassword = null) { public function changePassword(int $accountId, $currentPassword = null, $newPassword = null, $newRePassword = null) {
$this->route = "/v1/accounts/{$accountId}/password"; $this->getActor()->sendPOST("/v1/accounts/{$accountId}/password", [
$this->actor->sendPOST($this->getUrl(), [
'password' => $currentPassword, 'password' => $currentPassword,
'newPassword' => $newPassword, 'newPassword' => $newPassword,
'newRePassword' => $newRePassword, 'newRePassword' => $newRePassword,
@@ -23,55 +16,65 @@ class AccountsRoute extends BasePage {
} }
public function changeUsername(int $accountId, $currentPassword = null, $newUsername = null) { public function changeUsername(int $accountId, $currentPassword = null, $newUsername = null) {
$this->route = "/v1/accounts/{$accountId}/username"; $this->getActor()->sendPOST("/v1/accounts/{$accountId}/username", [
$this->actor->sendPOST($this->getUrl(), [
'password' => $currentPassword, 'password' => $currentPassword,
'username' => $newUsername, 'username' => $newUsername,
]); ]);
} }
public function changeEmailInitialize(int $accountId, $password = '') { public function changeEmailInitialize(int $accountId, $password = '') {
$this->route = "/v1/accounts/{$accountId}/email-verification"; $this->getActor()->sendPOST("/v1/accounts/{$accountId}/email-verification", [
$this->actor->sendPOST($this->getUrl(), [
'password' => $password, 'password' => $password,
]); ]);
} }
public function changeEmailSubmitNewEmail(int $accountId, $key = null, $email = null) { public function changeEmailSubmitNewEmail(int $accountId, $key = null, $email = null) {
$this->route = "/v1/accounts/{$accountId}/new-email-verification"; $this->getActor()->sendPOST("/v1/accounts/{$accountId}/new-email-verification", [
$this->actor->sendPOST($this->getUrl(), [
'key' => $key, 'key' => $key,
'email' => $email, 'email' => $email,
]); ]);
} }
public function changeEmail(int $accountId, $key = null) { public function changeEmail(int $accountId, $key = null) {
$this->route = "/v1/accounts/{$accountId}/email"; $this->getActor()->sendPOST("/v1/accounts/{$accountId}/email", [
$this->actor->sendPOST($this->getUrl(), [
'key' => $key, 'key' => $key,
]); ]);
} }
public function changeLanguage(int $accountId, $lang = null) { public function changeLanguage(int $accountId, $lang = null) {
$this->route = "/v1/accounts/{$accountId}/language"; $this->getActor()->sendPOST("/v1/accounts/{$accountId}/language", [
$this->actor->sendPOST($this->getUrl(), [
'lang' => $lang, 'lang' => $lang,
]); ]);
} }
public function acceptRules(int $accountId) { public function acceptRules(int $accountId) {
$this->route = "/v1/accounts/{$accountId}/rules"; $this->getActor()->sendPOST("/v1/accounts/{$accountId}/rules");
$this->actor->sendPOST($this->getUrl()); }
public function getTwoFactorAuthCredentials(int $accountId) {
$this->getActor()->sendGET("/v1/accounts/{$accountId}/two-factor-auth");
}
public function enableTwoFactorAuth(int $accountId, $totp = null, $password = null) {
$this->getActor()->sendPOST("/v1/accounts/{$accountId}/two-factor-auth", [
'totp' => $totp,
'password' => $password,
]);
}
public function disableTwoFactorAuth(int $accountId, $totp = null, $password = null) {
$this->getActor()->sendDELETE("/v1/accounts/{$accountId}/two-factor-auth", [
'totp' => $totp,
'password' => $password,
]);
} }
public function ban(int $accountId) { public function ban(int $accountId) {
$this->route = "/v1/accounts/{$accountId}/ban"; $this->getActor()->sendPOST("/v1/accounts/{$accountId}/ban");
$this->actor->sendPOST($this->getUrl());
} }
public function pardon($accountId) { public function pardon(int $accountId) {
$this->route = "/v1/accounts/{$accountId}/ban"; $this->getActor()->sendDELETE("/v1/accounts/{$accountId}/ban");
$this->actor->sendDELETE($this->getUrl());
} }
} }

View File

@@ -1,11 +1,6 @@
<?php <?php
namespace tests\codeception\api\_pages; namespace tests\codeception\api\_pages;
use yii\codeception\BasePage;
/**
* @property \tests\codeception\api\FunctionalTester $actor
*/
class AuthenticationRoute extends BasePage { class AuthenticationRoute extends BasePage {
/** /**
@@ -15,7 +10,6 @@ class AuthenticationRoute extends BasePage {
* @param bool $rememberMe * @param bool $rememberMe
*/ */
public function login($login = '', $password = '', $rememberMeOrToken = null, $rememberMe = false) { public function login($login = '', $password = '', $rememberMeOrToken = null, $rememberMe = false) {
$this->route = ['authentication/login'];
$params = [ $params = [
'login' => $login, 'login' => $login,
'password' => $password, 'password' => $password,
@@ -27,25 +21,22 @@ class AuthenticationRoute extends BasePage {
$params['totp'] = $rememberMeOrToken; $params['totp'] = $rememberMeOrToken;
} }
$this->actor->sendPOST($this->getUrl(), $params); $this->getActor()->sendPOST('/authentication/login', $params);
} }
public function logout() { public function logout() {
$this->route = ['authentication/logout']; $this->getActor()->sendPOST('/authentication/logout');
$this->actor->sendPOST($this->getUrl());
} }
public function forgotPassword($login = null, $token = null) { public function forgotPassword($login = null, $token = null) {
$this->route = ['authentication/forgot-password']; $this->getActor()->sendPOST('/authentication/forgot-password', [
$this->actor->sendPOST($this->getUrl(), [
'login' => $login, 'login' => $login,
'totp' => $token, 'totp' => $token,
]); ]);
} }
public function recoverPassword($key = null, $newPassword = null, $newRePassword = null) { public function recoverPassword($key = null, $newPassword = null, $newRePassword = null) {
$this->route = ['authentication/recover-password']; $this->getActor()->sendPOST('/authentication/recover-password', [
$this->actor->sendPOST($this->getUrl(), [
'key' => $key, 'key' => $key,
'newPassword' => $newPassword, 'newPassword' => $newPassword,
'newRePassword' => $newRePassword, 'newRePassword' => $newRePassword,
@@ -53,8 +44,7 @@ class AuthenticationRoute extends BasePage {
} }
public function refreshToken($refreshToken = null) { public function refreshToken($refreshToken = null) {
$this->route = ['authentication/refresh-token']; $this->getActor()->sendPOST('/authentication/refresh-token', [
$this->actor->sendPOST($this->getUrl(), [
'refresh_token' => $refreshToken, 'refresh_token' => $refreshToken,
]); ]);
} }

View File

@@ -1,36 +1,26 @@
<?php <?php
namespace tests\codeception\api\_pages; namespace tests\codeception\api\_pages;
use yii\codeception\BasePage;
/**
* @property \tests\codeception\api\FunctionalTester $actor
*/
class AuthserverRoute extends BasePage { class AuthserverRoute extends BasePage {
public function authenticate($params) { public function authenticate($params) {
$this->route = ['authserver/authentication/authenticate']; $this->getActor()->sendPOST('/authserver/authentication/authenticate', $params);
$this->actor->sendPOST($this->getUrl(), $params);
} }
public function refresh($params) { public function refresh($params) {
$this->route = ['authserver/authentication/refresh']; $this->getActor()->sendPOST('/authserver/authentication/refresh', $params);
$this->actor->sendPOST($this->getUrl(), $params);
} }
public function validate($params) { public function validate($params) {
$this->route = ['authserver/authentication/validate']; $this->getActor()->sendPOST('/authserver/authentication/validate', $params);
$this->actor->sendPOST($this->getUrl(), $params);
} }
public function invalidate($params) { public function invalidate($params) {
$this->route = ['authserver/authentication/invalidate']; $this->getActor()->sendPOST('/authserver/authentication/invalidate', $params);
$this->actor->sendPOST($this->getUrl(), $params);
} }
public function signout($params) { public function signout($params) {
$this->route = ['authserver/authentication/signout']; $this->getActor()->sendPOST('/authserver/authentication/signout', $params);
$this->actor->sendPOST($this->getUrl(), $params);
} }
} }

View File

@@ -0,0 +1,21 @@
<?php
namespace tests\codeception\api\_pages;
use tests\codeception\api\FunctionalTester;
class BasePage {
/**
* @var FunctionalTester
*/
private $actor;
public function __construct(FunctionalTester $I) {
$this->actor = $I;
}
public function getActor(): FunctionalTester {
return $this->actor;
}
}

View File

@@ -1,16 +1,10 @@
<?php <?php
namespace tests\codeception\api\_pages; namespace tests\codeception\api\_pages;
use yii\codeception\BasePage;
/**
* @property \tests\codeception\api\FunctionalTester $actor
*/
class IdentityInfoRoute extends BasePage { class IdentityInfoRoute extends BasePage {
public function info() { public function info() {
$this->route = ['identity-info/index']; $this->getActor()->sendGET('/account/v1/info');
$this->actor->sendGET($this->getUrl());
} }
} }

View File

@@ -1,16 +1,10 @@
<?php <?php
namespace tests\codeception\api\_pages; namespace tests\codeception\api\_pages;
use yii\codeception\BasePage;
/**
* @property \tests\codeception\api\FunctionalTester $actor
*/
class InternalRoute extends BasePage { class InternalRoute extends BasePage {
public function info(string $param, string $value) { public function info(string $param, string $value) {
$this->route = '/internal/accounts/info'; $this->getActor()->sendGET('/internal/accounts/info', [$param => $value]);
$this->actor->sendGET($this->getUrl(), [$param => $value]);
} }
} }

View File

@@ -1,20 +0,0 @@
<?php
namespace tests\codeception\api\_pages;
use yii\codeception\BasePage;
/**
* @property \tests\codeception\api\FunctionalTester $actor
*/
class LoginRoute extends BasePage {
public $route = ['authentication/login'];
public function login($login = '', $password = '') {
$this->actor->sendPOST($this->getUrl(), [
'login' => $login,
'password' => $password,
]);
}
}

View File

@@ -1,27 +1,19 @@
<?php <?php
namespace tests\codeception\api\_pages; namespace tests\codeception\api\_pages;
use yii\codeception\BasePage;
/**
* @property \tests\codeception\api\FunctionalTester $actor
*/
class MojangApiRoute extends BasePage { class MojangApiRoute extends BasePage {
public function usernameToUuid($username, $at = null) { public function usernameToUuid($username, $at = null) {
$this->route = '/mojang/profiles/' . $username;
$params = $at === null ? [] : ['at' => $at]; $params = $at === null ? [] : ['at' => $at];
$this->actor->sendGET($this->getUrl(), $params); $this->getActor()->sendGET("/mojang/profiles/{$username}", $params);
} }
public function usernamesByUuid($uuid) { public function usernamesByUuid($uuid) {
$this->route = "/mojang/profiles/{$uuid}/names"; $this->getActor()->sendGET("/mojang/profiles/{$uuid}/names");
$this->actor->sendGET($this->getUrl());
} }
public function uuidsByUsernames($uuids) { public function uuidsByUsernames($uuids) {
$this->route = '/mojang/profiles'; $this->getActor()->sendPOST('/mojang/profiles', $uuids);
$this->actor->sendPOST($this->getUrl(), $uuids);
} }
} }

View File

@@ -1,26 +1,18 @@
<?php <?php
namespace tests\codeception\api\_pages; namespace tests\codeception\api\_pages;
use yii\codeception\BasePage;
/**
* @property \tests\codeception\api\FunctionalTester $actor
*/
class OauthRoute extends BasePage { class OauthRoute extends BasePage {
public function validate($queryParams) { public function validate($queryParams) {
$this->route = '/oauth2/v1/validate'; $this->getActor()->sendGET('/oauth2/v1/validate', $queryParams);
$this->actor->sendGET($this->getUrl($queryParams));
} }
public function complete($queryParams = [], $postParams = []) { public function complete($queryParams = [], $postParams = []) {
$this->route = '/oauth2/v1/complete'; $this->getActor()->sendPOST('/oauth2/v1/complete?' . http_build_query($queryParams), $postParams);
$this->actor->sendPOST($this->getUrl($queryParams), $postParams);
} }
public function issueToken($postParams = []) { public function issueToken($postParams = []) {
$this->route = '/oauth2/v1/token'; $this->getActor()->sendPOST('/oauth2/v1/token', $postParams);
$this->actor->sendPOST($this->getUrl(), $postParams);
} }
} }

View File

@@ -1,16 +1,10 @@
<?php <?php
namespace tests\codeception\api\_pages; namespace tests\codeception\api\_pages;
use yii\codeception\BasePage;
/**
* @property \tests\codeception\api\FunctionalTester $actor
*/
class OptionsRoute extends BasePage { class OptionsRoute extends BasePage {
public function get() { public function get() {
$this->route = ['options/index']; $this->getActor()->sendGET('/options');
$this->actor->sendGET($this->getUrl());
} }
} }

View File

@@ -1,36 +1,26 @@
<?php <?php
namespace tests\codeception\api\_pages; namespace tests\codeception\api\_pages;
use yii\codeception\BasePage;
/**
* @property \tests\codeception\api\FunctionalTester $actor
*/
class SessionServerRoute extends BasePage { class SessionServerRoute extends BasePage {
public function join($params) { public function join($params) {
$this->route = '/minecraft/session/join'; $this->getActor()->sendPOST('/minecraft/session/join', $params);
$this->actor->sendPOST($this->getUrl(), $params);
} }
public function joinLegacy(array $params) { public function joinLegacy(array $params) {
$this->route = '/minecraft/session/legacy/join'; $this->getActor()->sendGET('/minecraft/session/legacy/join', $params);
$this->actor->sendGET($this->getUrl(), $params);
} }
public function hasJoined(array $params) { public function hasJoined(array $params) {
$this->route = '/minecraft/session/hasJoined'; $this->getActor()->sendGET('/minecraft/session/hasJoined', $params);
$this->actor->sendGET($this->getUrl(), $params);
} }
public function hasJoinedLegacy(array $params) { public function hasJoinedLegacy(array $params) {
$this->route = '/minecraft/session/legacy/hasJoined'; $this->getActor()->sendGET('/minecraft/session/legacy/hasJoined', $params);
$this->actor->sendGET($this->getUrl(), $params);
} }
public function profile($profileUuid) { public function profile($profileUuid) {
$this->route = '/minecraft/session/profile/' . $profileUuid; $this->getActor()->sendGET("/minecraft/session/profile/{$profileUuid}");
$this->actor->sendGET($this->getUrl());
} }
} }

View File

@@ -1,26 +1,18 @@
<?php <?php
namespace tests\codeception\api\_pages; namespace tests\codeception\api\_pages;
use yii\codeception\BasePage;
/**
* @property \tests\codeception\api\FunctionalTester $actor
*/
class SignupRoute extends BasePage { class SignupRoute extends BasePage {
public function register(array $registrationData) { public function register(array $registrationData) {
$this->route = ['signup/index']; $this->getActor()->sendPOST('/signup', $registrationData);
$this->actor->sendPOST($this->getUrl(), $registrationData);
} }
public function sendRepeatMessage($email = '') { public function sendRepeatMessage($email = '') {
$this->route = ['signup/repeat-message']; $this->getActor()->sendPOST('/signup/repeat-message', ['email' => $email]);
$this->actor->sendPOST($this->getUrl(), ['email' => $email]);
} }
public function confirm($key = '') { public function confirm($key = '') {
$this->route = ['signup/confirm']; $this->getActor()->sendPOST('/signup/confirm', [
$this->actor->sendPOST($this->getUrl(), [
'key' => $key, 'key' => $key,
]); ]);
} }

View File

@@ -1,36 +0,0 @@
<?php
namespace tests\codeception\api\_pages;
use yii\codeception\BasePage;
/**
* @property \tests\codeception\api\FunctionalTester $actor
*/
class TwoFactorAuthRoute extends BasePage {
public function credentials(int $accountId) {
$this->setRoute($accountId);
$this->actor->sendGET($this->getUrl());
}
public function enable(int $accountId, $totp = null, $password = null) {
$this->setRoute($accountId);
$this->actor->sendPOST($this->getUrl(), [
'totp' => $totp,
'password' => $password,
]);
}
public function disable(int $accountId, $totp = null, $password = null) {
$this->setRoute($accountId);
$this->actor->sendDELETE($this->getUrl(), [
'totp' => $totp,
'password' => $password,
]);
}
private function setRoute(int $accountId) {
$this->route = "/v1/accounts/{$accountId}/two-factor-auth";
}
}

View File

@@ -10,6 +10,7 @@ modules:
- Asserts - Asserts
- REST: - REST:
depends: Yii2 depends: Yii2
url: /api
config: config:
Yii2: Yii2:
configFile: '../config/api/functional.php' configFile: '../config/api/functional.php'

View File

@@ -6,7 +6,7 @@ use tests\codeception\api\_pages\AccountsRoute;
use tests\codeception\api\functional\_steps\OauthSteps; use tests\codeception\api\functional\_steps\OauthSteps;
use tests\codeception\api\FunctionalTester; use tests\codeception\api\FunctionalTester;
class AccountBanCest { class AccountsBanCest {
/** /**
* @var AccountsRoute * @var AccountsRoute

View File

@@ -2,24 +2,24 @@
namespace tests\codeception\api\functional; namespace tests\codeception\api\functional;
use OTPHP\TOTP; use OTPHP\TOTP;
use tests\codeception\api\_pages\TwoFactorAuthRoute; use tests\codeception\api\_pages\AccountsRoute;
use tests\codeception\api\FunctionalTester; use tests\codeception\api\FunctionalTester;
class TwoFactorAuthDisableCest { class AccountsDisableTwoFactorAuthCest {
/** /**
* @var TwoFactorAuthRoute * @var AccountsRoute
*/ */
private $route; private $route;
public function _before(FunctionalTester $I) { public function _before(FunctionalTester $I) {
$this->route = new TwoFactorAuthRoute($I); $this->route = new AccountsRoute($I);
} }
public function testFails(FunctionalTester $I) { public function testFails(FunctionalTester $I) {
$accountId = $I->amAuthenticated('AccountWithEnabledOtp'); $accountId = $I->amAuthenticated('AccountWithEnabledOtp');
$this->route->disable($accountId); $this->route->disableTwoFactorAuth($accountId);
$I->canSeeResponseContainsJson([ $I->canSeeResponseContainsJson([
'success' => false, 'success' => false,
'errors' => [ 'errors' => [
@@ -28,7 +28,7 @@ class TwoFactorAuthDisableCest {
], ],
]); ]);
$this->route->disable($accountId, '123456', 'invalid_password'); $this->route->disableTwoFactorAuth($accountId, '123456', 'invalid_password');
$I->canSeeResponseContainsJson([ $I->canSeeResponseContainsJson([
'success' => false, 'success' => false,
'errors' => [ 'errors' => [
@@ -38,7 +38,7 @@ class TwoFactorAuthDisableCest {
]); ]);
$accountId = $I->amAuthenticated('AccountWithOtpSecret'); $accountId = $I->amAuthenticated('AccountWithOtpSecret');
$this->route->disable($accountId, '123456', 'invalid_password'); $this->route->disableTwoFactorAuth($accountId, '123456', 'invalid_password');
$I->canSeeResponseContainsJson([ $I->canSeeResponseContainsJson([
'success' => false, 'success' => false,
'errors' => [ 'errors' => [
@@ -50,7 +50,7 @@ class TwoFactorAuthDisableCest {
public function testSuccessEnable(FunctionalTester $I) { public function testSuccessEnable(FunctionalTester $I) {
$accountId = $I->amAuthenticated('AccountWithEnabledOtp'); $accountId = $I->amAuthenticated('AccountWithEnabledOtp');
$totp = TOTP::create('BBBB'); $totp = TOTP::create('BBBB');
$this->route->disable($accountId, $totp->now(), 'password_0'); $this->route->disableTwoFactorAuth($accountId, $totp->now(), 'password_0');
$I->canSeeResponseCodeIs(200); $I->canSeeResponseCodeIs(200);
$I->canSeeResponseIsJson(); $I->canSeeResponseIsJson();
$I->canSeeResponseContainsJson([ $I->canSeeResponseContainsJson([

View File

@@ -2,24 +2,24 @@
namespace tests\codeception\api\functional; namespace tests\codeception\api\functional;
use OTPHP\TOTP; use OTPHP\TOTP;
use tests\codeception\api\_pages\TwoFactorAuthRoute; use tests\codeception\api\_pages\AccountsRoute;
use tests\codeception\api\FunctionalTester; use tests\codeception\api\FunctionalTester;
class TwoFactorAuthEnableCest { class AccountsEnableTwoFactorAuthCest {
/** /**
* @var TwoFactorAuthRoute * @var AccountsRoute
*/ */
private $route; private $route;
public function _before(FunctionalTester $I) { public function _before(FunctionalTester $I) {
$this->route = new TwoFactorAuthRoute($I); $this->route = new AccountsRoute($I);
} }
public function testFails(FunctionalTester $I) { public function testFails(FunctionalTester $I) {
$accountId = $I->amAuthenticated('AccountWithOtpSecret'); $accountId = $I->amAuthenticated('AccountWithOtpSecret');
$this->route->enable($accountId); $this->route->enableTwoFactorAuth($accountId);
$I->canSeeResponseContainsJson([ $I->canSeeResponseContainsJson([
'success' => false, 'success' => false,
'errors' => [ 'errors' => [
@@ -28,7 +28,7 @@ class TwoFactorAuthEnableCest {
], ],
]); ]);
$this->route->enable($accountId, '123456', 'invalid_password'); $this->route->enableTwoFactorAuth($accountId, '123456', 'invalid_password');
$I->canSeeResponseContainsJson([ $I->canSeeResponseContainsJson([
'success' => false, 'success' => false,
'errors' => [ 'errors' => [
@@ -38,7 +38,7 @@ class TwoFactorAuthEnableCest {
]); ]);
$accountId = $I->amAuthenticated('AccountWithEnabledOtp'); $accountId = $I->amAuthenticated('AccountWithEnabledOtp');
$this->route->enable($accountId, '123456', 'invalid_password'); $this->route->enableTwoFactorAuth($accountId, '123456', 'invalid_password');
$I->canSeeResponseContainsJson([ $I->canSeeResponseContainsJson([
'success' => false, 'success' => false,
'errors' => [ 'errors' => [
@@ -50,7 +50,7 @@ class TwoFactorAuthEnableCest {
public function testSuccessEnable(FunctionalTester $I) { public function testSuccessEnable(FunctionalTester $I) {
$accountId = $I->amAuthenticated('AccountWithOtpSecret'); $accountId = $I->amAuthenticated('AccountWithOtpSecret');
$totp = TOTP::create('AAAA'); $totp = TOTP::create('AAAA');
$this->route->enable($accountId, $totp->now(), 'password_0'); $this->route->enableTwoFactorAuth($accountId, $totp->now(), 'password_0');
$I->canSeeResponseCodeIs(200); $I->canSeeResponseCodeIs(200);
$I->canSeeResponseIsJson(); $I->canSeeResponseIsJson();
$I->canSeeResponseContainsJson([ $I->canSeeResponseContainsJson([

View File

@@ -6,7 +6,7 @@ use tests\codeception\api\_pages\AccountsRoute;
use tests\codeception\api\functional\_steps\OauthSteps; use tests\codeception\api\functional\_steps\OauthSteps;
use tests\codeception\api\FunctionalTester; use tests\codeception\api\FunctionalTester;
class AccountPardonCest { class AccountsPardonCest {
/** /**
* @var AccountsRoute * @var AccountsRoute

View File

@@ -1,23 +1,23 @@
<?php <?php
namespace tests\codeception\api\functional; namespace tests\codeception\api\functional;
use tests\codeception\api\_pages\TwoFactorAuthRoute; use tests\codeception\api\_pages\AccountsRoute;
use tests\codeception\api\FunctionalTester; use tests\codeception\api\FunctionalTester;
class TwoFactorAuthCredentialsCest { class AccountsTwoFactorAuthCredentialsCest {
/** /**
* @var TwoFactorAuthRoute * @var AccountsRoute
*/ */
private $route; private $route;
public function _before(FunctionalTester $I) { public function _before(FunctionalTester $I) {
$this->route = new TwoFactorAuthRoute($I); $this->route = new AccountsRoute($I);
} }
public function testGetCredentials(FunctionalTester $I) { public function testGetCredentials(FunctionalTester $I) {
$accountId = $I->amAuthenticated(); $accountId = $I->amAuthenticated();
$this->route->credentials($accountId); $this->route->getTwoFactorAuthCredentials($accountId);
$I->canSeeResponseCodeIs(200); $I->canSeeResponseCodeIs(200);
$I->canSeeResponseIsJson(); $I->canSeeResponseIsJson();
$I->canSeeResponseJsonMatchesJsonPath('$.secret'); $I->canSeeResponseJsonMatchesJsonPath('$.secret');