Remove usage of codeception/specify and fzaninotto/faker

This commit is contained in:
ErickSkrauch
2019-12-21 02:26:06 +03:00
parent 666213afc7
commit 43a4a58053
19 changed files with 217 additions and 613 deletions

View File

@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace api\models\authentication;
use api\aop\annotations\CollectModelMetrics;

View File

@@ -4,7 +4,7 @@ namespace api\tests\functional\_steps;
use api\rbac\Permissions as P;
use api\tests\_pages\SessionServerRoute;
use api\tests\FunctionalTester;
use Faker\Provider\Uuid;
use function Ramsey\Uuid\v4 as uuid;
class SessionServerSteps extends FunctionalTester {
@@ -12,7 +12,7 @@ class SessionServerSteps extends FunctionalTester {
$oauthSteps = new OauthSteps($this->scenario);
$accessToken = $oauthSteps->getAccessToken([P::MINECRAFT_SERVER_SESSION]);
$route = new SessionServerRoute($this);
$serverId = Uuid::uuid();
$serverId = uuid();
$username = 'Admin';
if ($byLegacy) {

View File

@@ -3,7 +3,7 @@ namespace api\tests\functional\authserver;
use api\tests\_pages\MojangApiRoute;
use api\tests\FunctionalTester;
use Faker\Provider\Uuid;
use function Ramsey\Uuid\v4 as uuid;
class UuidToUsernamesHistoryCest {
@@ -50,7 +50,7 @@ class UuidToUsernamesHistoryCest {
public function passWrongUuid(FunctionalTester $I) {
$I->wantTo('get user username by some wrong uuid');
$this->route->usernamesByUuid(Uuid::uuid());
$this->route->usernamesByUuid(uuid());
$I->canSeeResponseCodeIs(204);
$I->canSeeResponseEquals('');
}

View File

@@ -4,7 +4,7 @@ namespace api\tests\functional\sessionserver;
use api\tests\_pages\SessionServerRoute;
use api\tests\functional\_steps\SessionServerSteps;
use api\tests\FunctionalTester;
use Faker\Provider\Uuid;
use function Ramsey\Uuid\v4 as uuid;
class HasJoinedCest {
@@ -46,7 +46,7 @@ class HasJoinedCest {
$I->wantTo('hasJoined to some server without join call');
$this->route->hasJoined([
'username' => 'some-username',
'serverId' => Uuid::uuid(),
'serverId' => uuid(),
]);
$I->seeResponseCodeIs(401);
$I->seeResponseIsJson();

View File

@@ -4,7 +4,7 @@ namespace api\tests\functional\sessionserver;
use api\tests\_pages\SessionServerRoute;
use api\tests\functional\_steps\SessionServerSteps;
use api\tests\FunctionalTester;
use Faker\Provider\Uuid;
use function Ramsey\Uuid\v4 as uuid;
class HasJoinedLegacyCest {
@@ -42,7 +42,7 @@ class HasJoinedLegacyCest {
$I->wantTo('hasJoined by legacy version to some server without join call');
$this->route->hasJoinedLegacy([
'user' => 'random-username',
'serverId' => Uuid::uuid(),
'serverId' => uuid(),
]);
$I->seeResponseCodeIs(200);
$I->canSeeResponseEquals('NO');

View File

@@ -6,7 +6,7 @@ use api\tests\_pages\SessionServerRoute;
use api\tests\functional\_steps\AuthserverSteps;
use api\tests\functional\_steps\OauthSteps;
use api\tests\FunctionalTester;
use Faker\Provider\Uuid;
use function Ramsey\Uuid\v4 as uuid;
class JoinCest {
@@ -25,7 +25,7 @@ class JoinCest {
$this->route->join([
'accessToken' => $accessToken,
'selectedProfile' => 'df936908-b2e1-544d-96f8-2977ec213022',
'serverId' => Uuid::uuid(),
'serverId' => uuid(),
]);
$this->expectSuccessResponse($I);
}
@@ -36,7 +36,7 @@ class JoinCest {
$this->route->join(json_encode([
'accessToken' => $accessToken,
'selectedProfile' => 'df936908-b2e1-544d-96f8-2977ec213022',
'serverId' => Uuid::uuid(),
'serverId' => uuid(),
]));
$this->expectSuccessResponse($I);
}
@@ -47,7 +47,7 @@ class JoinCest {
$this->route->join([
'accessToken' => $accessToken,
'selectedProfile' => 'df936908-b2e1-544d-96f8-2977ec213022',
'serverId' => Uuid::uuid(),
'serverId' => uuid(),
]);
$this->expectSuccessResponse($I);
}
@@ -58,7 +58,7 @@ class JoinCest {
$this->route->join([
'accessToken' => $accessToken,
'selectedProfile' => 'df936908b2e1544d96f82977ec213022',
'serverId' => Uuid::uuid(),
'serverId' => uuid(),
]);
$this->expectSuccessResponse($I);
}
@@ -69,7 +69,7 @@ class JoinCest {
$this->route->join([
'accessToken' => $accessToken,
'selectedProfile' => 'df936908-b2e1-544d-96f8-2977ec213022',
'serverId' => Uuid::uuid(),
'serverId' => uuid(),
]);
$I->seeResponseCodeIs(401);
$I->seeResponseIsJson();
@@ -84,7 +84,7 @@ class JoinCest {
$this->route->join([
'accessToken' => '6042634a-a1e2-4aed-866c-c661fe4e63e2',
'selectedProfile' => 'df936908-b2e1-544d-96f8-2977ec213022',
'serverId' => Uuid::uuid(),
'serverId' => uuid(),
]);
$I->seeResponseCodeIs(401);
$I->seeResponseIsJson();
@@ -110,9 +110,9 @@ class JoinCest {
public function joinWithWrongAccessToken(FunctionalTester $I) {
$I->wantTo('join to some server with wrong accessToken');
$this->route->join([
'accessToken' => Uuid::uuid(),
'accessToken' => uuid(),
'selectedProfile' => 'df936908-b2e1-544d-96f8-2977ec213022',
'serverId' => Uuid::uuid(),
'serverId' => uuid(),
]);
$I->seeResponseCodeIs(401);
$I->seeResponseIsJson();
@@ -127,7 +127,7 @@ class JoinCest {
$this->route->join([
'accessToken' => '00000000-0000-0000-0000-000000000000',
'selectedProfile' => 'df936908-b2e1-544d-96f8-2977ec213022',
'serverId' => Uuid::uuid(),
'serverId' => uuid(),
]);
$I->canSeeResponseCodeIs(400);
$I->canSeeResponseIsJson();

View File

@@ -6,7 +6,7 @@ use api\tests\_pages\SessionServerRoute;
use api\tests\functional\_steps\AuthserverSteps;
use api\tests\functional\_steps\OauthSteps;
use api\tests\FunctionalTester;
use Faker\Provider\Uuid;
use function Ramsey\Uuid\v4 as uuid;
class JoinLegacyCest {
@@ -25,7 +25,7 @@ class JoinLegacyCest {
$this->route->joinLegacy([
'sessionId' => $accessToken,
'user' => 'Admin',
'serverId' => Uuid::uuid(),
'serverId' => uuid(),
]);
$this->expectSuccessResponse($I);
}
@@ -36,7 +36,7 @@ class JoinLegacyCest {
$this->route->joinLegacy([
'sessionId' => $accessToken,
'user' => 'admin',
'serverId' => Uuid::uuid(),
'serverId' => uuid(),
]);
$this->expectSuccessResponse($I);
}
@@ -47,7 +47,7 @@ class JoinLegacyCest {
$this->route->joinLegacy([
'sessionId' => 'token:' . $accessToken . ':' . 'df936908-b2e1-544d-96f8-2977ec213022',
'user' => 'Admin',
'serverId' => Uuid::uuid(),
'serverId' => uuid(),
]);
$this->expectSuccessResponse($I);
}
@@ -58,7 +58,7 @@ class JoinLegacyCest {
$this->route->joinLegacy([
'sessionId' => 'token:' . $accessToken . ':' . 'df936908-b2e1-544d-96f8-2977ec213022',
'user' => 'Admin',
'serverId' => Uuid::uuid(),
'serverId' => uuid(),
]);
$this->expectSuccessResponse($I);
}
@@ -75,9 +75,9 @@ class JoinLegacyCest {
public function joinWithWrongAccessToken(FunctionalTester $I) {
$I->wantTo('join to some server with wrong accessToken');
$this->route->joinLegacy([
'sessionId' => 'token:' . Uuid::uuid() . ':' . Uuid::uuid(),
'sessionId' => 'token:' . uuid() . ':' . uuid(),
'user' => 'random-username',
'serverId' => Uuid::uuid(),
'serverId' => uuid(),
]);
$I->seeResponseCodeIs(401);
$I->canSeeResponseContains('Ely.by authorization required');
@@ -89,7 +89,7 @@ class JoinLegacyCest {
$this->route->joinLegacy([
'sessionId' => 'token:' . $accessToken . ':' . 'df936908-b2e1-544d-96f8-2977ec213022',
'user' => 'Admin',
'serverId' => Uuid::uuid(),
'serverId' => uuid(),
]);
$I->seeResponseCodeIs(401);
$I->canSeeResponseContains('Ely.by authorization required');
@@ -100,7 +100,7 @@ class JoinLegacyCest {
$this->route->joinLegacy([
'sessionId' => 'token:00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000',
'user' => 'SomeUser',
'serverId' => Uuid::uuid(),
'serverId' => uuid(),
]);
$I->canSeeResponseCodeIs(400);
$I->canSeeResponseContains('credentials can not be null.');

View File

@@ -4,7 +4,7 @@ namespace api\tests\functional\sessionserver;
use api\tests\_pages\SessionServerRoute;
use api\tests\functional\_steps\SessionServerSteps;
use api\tests\FunctionalTester;
use Faker\Provider\Uuid;
use function Ramsey\Uuid\v4;
class ProfileCest {
@@ -48,7 +48,7 @@ class ProfileCest {
public function getProfileWithNonexistentUuid(FunctionalTester $I) {
$I->wantTo('get info about nonexistent uuid');
$this->route->profile(Uuid::uuid());
$this->route->profile(v4());
$I->canSeeResponseCodeIs(401);
$I->canSeeResponseIsJson();
$I->seeResponseIsJson();

View File

@@ -5,26 +5,11 @@ namespace api\tests\_support\models\authentication;
use api\models\authentication\LoginForm;
use api\tests\unit\TestCase;
use Codeception\Specify;
use common\models\Account;
use common\tests\fixtures\AccountFixture;
use OTPHP\TOTP;
class LoginFormTest extends TestCase {
use Specify;
private $originalRemoteAddr;
protected function setUp(): void {
$this->originalRemoteAddr = $_SERVER['REMOTE_ADDR'] ?? null;
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
parent::setUp();
}
protected function tearDown(): void {
parent::tearDown();
$_SERVER['REMOTE_ADDR'] = $this->originalRemoteAddr;
}
public function _fixtures(): array {
return [
@@ -33,43 +18,31 @@ class LoginFormTest extends TestCase {
}
public function testValidateLogin() {
$this->specify('error.login_not_exist if login not exists', function() {
$model = $this->createModel([
'login' => 'mr-test',
'account' => null,
]);
$model->validateLogin('login');
$this->assertSame(['error.login_not_exist'], $model->getErrors('login'));
});
$model = $this->createWithAccount(null);
$model->login = 'mock-login';
$model->validateLogin('login');
$this->assertSame(['error.login_not_exist'], $model->getErrors('login'));
$this->specify('no errors if login exists', function() {
$model = $this->createModel([
'login' => 'mr-test',
'account' => new Account(),
]);
$model->validateLogin('login');
$this->assertEmpty($model->getErrors('login'));
});
$model = $this->createWithAccount(new Account());
$model->login = 'mock-login';
$model->validateLogin('login');
$this->assertEmpty($model->getErrors('login'));
}
public function testValidatePassword() {
$this->specify('error.password_incorrect if password invalid', function() {
$model = $this->createModel([
'password' => '87654321',
'account' => new Account(['password' => '12345678']),
]);
$model->validatePassword('password');
$this->assertSame(['error.password_incorrect'], $model->getErrors('password'));
});
$account = new Account();
$account->password_hash = '$2y$04$N0q8DaHzlYILCnLYrpZfEeWKEqkPZzbawiS07GbSr/.xbRNweSLU6'; // 12345678
$account->password_hash_strategy = Account::PASS_HASH_STRATEGY_YII2;
$this->specify('no errors if password valid', function() {
$model = $this->createModel([
'password' => '12345678',
'account' => new Account(['password' => '12345678']),
]);
$model->validatePassword('password');
$this->assertEmpty($model->getErrors('password'));
});
$model = $this->createWithAccount($account);
$model->password = '87654321';
$model->validatePassword('password');
$this->assertSame(['error.password_incorrect'], $model->getErrors('password'));
$model = $this->createWithAccount($account);
$model->password = '12345678';
$model->validatePassword('password');
$this->assertEmpty($model->getErrors('password'));
}
public function testValidateTotp() {
@@ -78,99 +51,72 @@ class LoginFormTest extends TestCase {
$account->is_otp_enabled = true;
$account->otp_secret = 'AAAA';
$this->specify('error.totp_incorrect if totp invalid', function() use ($account) {
$model = $this->createModel([
'password' => '12345678',
'totp' => '321123',
'account' => $account,
]);
$model->validateTotp('totp');
$this->assertSame(['error.totp_incorrect'], $model->getErrors('totp'));
});
$model = $this->createWithAccount($account);
$model->password = '12345678';
$model->totp = '321123';
$model->validateTotp('totp');
$this->assertSame(['error.totp_incorrect'], $model->getErrors('totp'));
$totp = TOTP::create($account->otp_secret);
$this->specify('no errors if password valid', function() use ($account, $totp) {
$model = $this->createModel([
'password' => '12345678',
'totp' => $totp->now(),
'account' => $account,
]);
$model->validateTotp('totp');
$this->assertEmpty($model->getErrors('totp'));
});
$model = $this->createWithAccount($account);
$model->password = '12345678';
$model->totp = $totp->now();
$model->validateTotp('totp');
$this->assertEmpty($model->getErrors('totp'));
}
public function testValidateActivity() {
$this->specify('error.account_not_activated if account in not activated state', function() {
$model = $this->createModel([
'account' => new Account(['status' => Account::STATUS_REGISTERED]),
]);
$model->validateActivity('login');
$this->assertSame(['error.account_not_activated'], $model->getErrors('login'));
});
$account = new Account();
$account->status = Account::STATUS_REGISTERED;
$model = $this->createWithAccount($account);
$model->validateActivity('login');
$this->assertSame(['error.account_not_activated'], $model->getErrors('login'));
$this->specify('error.account_banned if account has banned status', function() {
$model = $this->createModel([
'account' => new Account(['status' => Account::STATUS_BANNED]),
]);
$model->validateActivity('login');
$this->assertSame(['error.account_banned'], $model->getErrors('login'));
});
$account = new Account();
$account->status = Account::STATUS_BANNED;
$model = $this->createWithAccount($account);
$model->validateActivity('login');
$this->assertSame(['error.account_banned'], $model->getErrors('login'));
$this->specify('no errors if account active', function() {
$model = $this->createModel([
'account' => new Account(['status' => Account::STATUS_ACTIVE]),
]);
$model->validateActivity('login');
$this->assertEmpty($model->getErrors('login'));
});
$account = new Account();
$account->status = Account::STATUS_ACTIVE;
$model = $this->createWithAccount($account);
$model->validateActivity('login');
$this->assertEmpty($model->getErrors('login'));
}
public function testLogin() {
$model = $this->createModel([
'login' => 'erickskrauch',
'password' => '12345678',
'account' => new Account([
'id' => 1,
'username' => 'erickskrauch',
'password' => '12345678',
'status' => Account::STATUS_ACTIVE,
]),
]);
$account = new Account();
$account->id = 1;
$account->username = 'erickskrauch';
$account->password_hash = '$2y$04$N0q8DaHzlYILCnLYrpZfEeWKEqkPZzbawiS07GbSr/.xbRNweSLU6'; // 12345678
$account->password_hash_strategy = Account::PASS_HASH_STRATEGY_YII2;
$account->status = Account::STATUS_ACTIVE;
$model = $this->createWithAccount($account);
$model->login = 'erickskrauch';
$model->password = '12345678';
$this->assertNotNull($model->login(), 'model should login user');
$this->assertEmpty($model->getErrors(), 'error message should not be set');
}
public function testLoginWithRehashing() {
$model = new LoginForm([
'login' => $this->tester->grabFixture('accounts', 'user-with-old-password-type')['username'],
'password' => '12345678',
]);
/** @var Account $account */
$account = $this->tester->grabFixture('accounts', 'user-with-old-password-type');
$model = $this->createWithAccount($account);
$model->login = $account->username;
$model->password = '12345678';
$this->assertNotNull($model->login());
$this->assertEmpty($model->getErrors());
$this->assertSame(
Account::PASS_HASH_STRATEGY_YII2,
$model->getAccount()->password_hash_strategy,
'user, that login using account with old pass hash strategy should update it automatically'
);
$this->assertSame(Account::PASS_HASH_STRATEGY_YII2, $account->password_hash_strategy);
$this->assertNotSame('133c00c463cbd3e491c28cb653ce4718', $account->password_hash);
}
/**
* @param array $params
* @return LoginForm
*/
private function createModel(array $params = []) {
return new class($params) extends LoginForm {
private $_account;
private function createWithAccount(?Account $account): LoginForm {
$model = $this->createPartialMock(LoginForm::class, ['getAccount']);
$model->method('getAccount')->willReturn($account);
public function setAccount($value) {
$this->_account = $value;
}
public function getAccount(): ?Account {
return $this->_account;
}
};
return $model;
}
}

View File

@@ -6,54 +6,32 @@ namespace api\tests\_support\models\authentication;
use api\components\User\Component;
use api\models\authentication\LogoutForm;
use api\tests\unit\TestCase;
use Codeception\Specify;
use common\models\AccountSession;
use Yii;
class LogoutFormTest extends TestCase {
use Specify;
public function testValidateLogout() {
$this->specify('No actions if active session is not exists', function() {
$userComp = $this
->getMockBuilder(Component::class)
->setMethods(['getActiveSession'])
->getMock();
$userComp
->expects($this->any())
->method('getActiveSession')
->will($this->returnValue(null));
public function testNoActionWhenThereIsNoActiveSession() {
$userComp = $this->createPartialMock(Component::class, ['getActiveSession']);
$userComp->method('getActiveSession')->willReturn(null);
Yii::$app->set('user', $userComp);
Yii::$app->set('user', $userComp);
$model = new LogoutForm();
$this->assertTrue($model->logout());
});
$model = new LogoutForm();
$this->assertTrue($model->logout());
}
$this->specify('if active session is presented, then delete should be called', function() {
$session = $this
->getMockBuilder(AccountSession::class)
->setMethods(['delete'])
->getMock();
$session
->expects($this->once())
->method('delete')
->willReturn(true);
public function testActiveSessionShouldBeDeleted() {
$session = $this->createPartialMock(AccountSession::class, ['delete']);
$session->expects($this->once())->method('delete')->willReturn(true);
$userComp = $this
->getMockBuilder(Component::class)
->setMethods(['getActiveSession'])
->getMock();
$userComp
->expects($this->any())
->method('getActiveSession')
->will($this->returnValue($session));
$userComp = $this->createPartialMock(Component::class, ['getActiveSession']);
$userComp->method('getActiveSession')->willReturn($session);
Yii::$app->set('user', $userComp);
Yii::$app->set('user', $userComp);
$model = new LogoutForm();
$model->logout();
});
$model = new LogoutForm();
$model->logout();
}
}

View File

@@ -6,9 +6,8 @@ namespace api\tests\_support\models\authentication;
use api\components\ReCaptcha\Validator as ReCaptchaValidator;
use api\models\authentication\RepeatAccountActivationForm;
use api\tests\unit\TestCase;
use Codeception\Specify;
use common\models\Account;
use common\models\confirmations\RegistrationConfirmation;
use common\models\EmailActivation;
use common\tasks\SendRegistrationEmail;
use common\tests\fixtures\AccountFixture;
use common\tests\fixtures\EmailActivationFixture;
@@ -16,7 +15,6 @@ use GuzzleHttp\ClientInterface;
use Yii;
class RepeatAccountActivationFormTest extends TestCase {
use Specify;
protected function setUp(): void {
parent::setUp();
@@ -35,41 +33,35 @@ class RepeatAccountActivationFormTest extends TestCase {
}
public function testValidateEmailForAccount() {
$this->specify('error.email_not_found if passed valid email, but it don\'t exists in database', function() {
$model = new RepeatAccountActivationForm(['email' => 'me-is-not@exists.net']);
$model->validateEmailForAccount('email');
$this->assertSame(['error.email_not_found'], $model->getErrors('email'));
});
$model = $this->createWithAccount(null);
$model->validateEmailForAccount('email');
$this->assertSame(['error.email_not_found'], $model->getErrors('email'));
$this->specify('error.account_already_activated if passed valid email, but account already activated', function() {
$fixture = $this->tester->grabFixture('accounts', 'admin');
$model = new RepeatAccountActivationForm(['email' => $fixture['email']]);
$model->validateEmailForAccount('email');
$this->assertSame(['error.account_already_activated'], $model->getErrors('email'));
});
$account = new Account();
$account->status = Account::STATUS_ACTIVE;
$model = $this->createWithAccount($account);
$model->validateEmailForAccount('email');
$this->assertSame(['error.account_already_activated'], $model->getErrors('email'));
$this->specify('no errors if passed valid email for not activated account', function() {
$fixture = $this->tester->grabFixture('accounts', 'not-activated-account');
$model = new RepeatAccountActivationForm(['email' => $fixture['email']]);
$model->validateEmailForAccount('email');
$this->assertEmpty($model->getErrors('email'));
});
$account = new Account();
$account->status = Account::STATUS_REGISTERED;
$model = $this->createWithAccount($account);
$model->validateEmailForAccount('email');
$this->assertEmpty($model->getErrors('email'));
}
public function testValidateExistsActivation() {
$this->specify('error.recently_sent_message if passed email has recently sent message', function() {
$fixture = $this->tester->grabFixture('activations', 'freshRegistrationConfirmation');
$model = $this->createModel(['emailKey' => $fixture['key']]);
$model->validateExistsActivation('email');
$this->assertSame(['error.recently_sent_message'], $model->getErrors('email'));
});
$activation = new RegistrationConfirmation();
$activation->created_at = time() - 10;
$model = $this->createWithActivation($activation);
$model->validateExistsActivation('email');
$this->assertSame(['error.recently_sent_message'], $model->getErrors('email'));
$this->specify('no errors if passed email has expired activation message', function() {
$fixture = $this->tester->grabFixture('activations', 'oldRegistrationConfirmation');
$model = $this->createModel(['emailKey' => $fixture['key']]);
$model->validateExistsActivation('email');
$this->assertEmpty($model->getErrors('email'));
});
$activation = new RegistrationConfirmation();
$activation->created_at = time() - 60 * 60 * 24;
$model = $this->createWithActivation($activation);
$model->validateExistsActivation('email');
$this->assertEmpty($model->getErrors('email'));
}
public function testSendRepeatMessage() {
@@ -93,18 +85,18 @@ class RepeatAccountActivationFormTest extends TestCase {
$this->assertSame('http://localhost/activation/' . $activation->key, $job->link);
}
/**
* @param array $params
* @return RepeatAccountActivationForm
*/
private function createModel(array $params = []) {
return new class($params) extends RepeatAccountActivationForm {
public $emailKey;
private function createWithAccount(?Account $account): RepeatAccountActivationForm {
$model = $this->createPartialMock(RepeatAccountActivationForm::class, ['getAccount']);
$model->method('getAccount')->willReturn($account);
public function getActivation(): ?RegistrationConfirmation {
return EmailActivation::findOne($this->emailKey);
}
};
return $model;
}
private function createWithActivation(?RegistrationConfirmation $activation): RepeatAccountActivationForm {
$model = $this->createPartialMock(RepeatAccountActivationForm::class, ['getActivation']);
$model->method('getActivation')->willReturn($activation);
return $model;
}
}

View File

@@ -6,7 +6,6 @@ namespace api\tests\unit\modules\session\filters;
use api\modules\session\filters\RateLimiter;
use api\tests\unit\TestCase;
use common\models\OauthClient;
use Faker\Provider\Internet;
use Yii;
use yii\redis\Connection;
use yii\web\Request;
@@ -84,7 +83,7 @@ class RateLimiterTest extends TestCase {
->getMock();
$request->method('getUserIp')
->willReturn(Internet::localIpv4());
->willReturn('10.1.1.17');
/** @var RateLimiter|\PHPUnit\Framework\MockObject\MockObject $filter */
$filter = $this->getMockBuilder(RateLimiter::class)