2016-12-18 04:50:53 +05:30
|
|
|
<?php
|
2017-09-19 22:36:16 +05:30
|
|
|
namespace tests\codeception\api\functional;
|
2016-12-18 04:50:53 +05:30
|
|
|
|
2017-09-19 22:36:16 +05:30
|
|
|
use common\rbac\Permissions as P;
|
|
|
|
use tests\codeception\api\_pages\AccountsRoute;
|
2016-12-18 04:50:53 +05:30
|
|
|
use tests\codeception\api\functional\_steps\OauthSteps;
|
|
|
|
use tests\codeception\api\FunctionalTester;
|
|
|
|
|
2017-09-19 22:36:16 +05:30
|
|
|
class AccountBanCest {
|
2016-12-18 04:50:53 +05:30
|
|
|
|
|
|
|
/**
|
2017-09-19 22:36:16 +05:30
|
|
|
* @var AccountsRoute
|
2016-12-18 04:50:53 +05:30
|
|
|
*/
|
|
|
|
private $route;
|
|
|
|
|
|
|
|
public function _before(FunctionalTester $I) {
|
2017-09-19 22:36:16 +05:30
|
|
|
$this->route = new AccountsRoute($I);
|
2016-12-18 04:50:53 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
public function testBanAccount(OauthSteps $I) {
|
2017-09-19 22:36:16 +05:30
|
|
|
$accessToken = $I->getAccessTokenByClientCredentialsGrant([P::BLOCK_ACCOUNT]);
|
2016-12-18 04:50:53 +05:30
|
|
|
$I->amBearerAuthenticated($accessToken);
|
|
|
|
|
|
|
|
$this->route->ban(1);
|
|
|
|
$I->canSeeResponseCodeIs(200);
|
|
|
|
$I->canSeeResponseIsJson();
|
|
|
|
$I->canSeeResponseContainsJson([
|
|
|
|
'success' => true,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testBanBannedAccount(OauthSteps $I) {
|
2017-09-19 22:36:16 +05:30
|
|
|
$accessToken = $I->getAccessTokenByClientCredentialsGrant([P::BLOCK_ACCOUNT]);
|
2016-12-18 04:50:53 +05:30
|
|
|
$I->amBearerAuthenticated($accessToken);
|
|
|
|
|
|
|
|
$this->route->ban(10);
|
|
|
|
$I->canSeeResponseCodeIs(200);
|
|
|
|
$I->canSeeResponseIsJson();
|
|
|
|
$I->canSeeResponseContainsJson([
|
|
|
|
'success' => false,
|
|
|
|
'errors' => [
|
|
|
|
'account' => 'error.account_already_banned',
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|