2016-12-18 02:20:53 +03:00
|
|
|
<?php
|
2019-02-20 22:58:52 +03:00
|
|
|
namespace api\tests\functional\accounts;
|
2016-12-18 02:20:53 +03:00
|
|
|
|
2019-08-02 03:29:20 +03:00
|
|
|
use api\rbac\Permissions as P;
|
2019-02-20 22:58:52 +03:00
|
|
|
use api\tests\_pages\AccountsRoute;
|
|
|
|
use api\tests\functional\_steps\OauthSteps;
|
|
|
|
use api\tests\FunctionalTester;
|
2016-12-18 02:20:53 +03:00
|
|
|
|
2017-10-01 03:29:00 +03:00
|
|
|
class BanCest {
|
2016-12-18 02:20:53 +03:00
|
|
|
|
2024-12-02 15:10:55 +05:00
|
|
|
private AccountsRoute $route;
|
2016-12-18 02:20:53 +03:00
|
|
|
|
2024-12-02 15:10:55 +05:00
|
|
|
public function _before(FunctionalTester $I): void {
|
2017-09-19 20:06:16 +03:00
|
|
|
$this->route = new AccountsRoute($I);
|
2016-12-18 02:20:53 +03:00
|
|
|
}
|
|
|
|
|
2024-12-02 15:10:55 +05:00
|
|
|
public function testBanAccount(OauthSteps $I): void {
|
2017-09-19 20:06:16 +03:00
|
|
|
$accessToken = $I->getAccessTokenByClientCredentialsGrant([P::BLOCK_ACCOUNT]);
|
2016-12-18 02:20:53 +03:00
|
|
|
$I->amBearerAuthenticated($accessToken);
|
|
|
|
|
|
|
|
$this->route->ban(1);
|
|
|
|
$I->canSeeResponseCodeIs(200);
|
|
|
|
$I->canSeeResponseIsJson();
|
|
|
|
$I->canSeeResponseContainsJson([
|
|
|
|
'success' => true,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2024-12-02 15:10:55 +05:00
|
|
|
public function testBanBannedAccount(OauthSteps $I): void {
|
2017-09-19 20:06:16 +03:00
|
|
|
$accessToken = $I->getAccessTokenByClientCredentialsGrant([P::BLOCK_ACCOUNT]);
|
2016-12-18 02:20:53 +03:00
|
|
|
$I->amBearerAuthenticated($accessToken);
|
|
|
|
|
|
|
|
$this->route->ban(10);
|
|
|
|
$I->canSeeResponseCodeIs(200);
|
|
|
|
$I->canSeeResponseIsJson();
|
|
|
|
$I->canSeeResponseContainsJson([
|
|
|
|
'success' => false,
|
|
|
|
'errors' => [
|
|
|
|
'account' => 'error.account_already_banned',
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|