use Symfony\Component\RateLimiter\RateLimit;
trait RateLimiterTestTrait
{ use IntegrationTestBehaviour;
/**
* @param array<string, int> $factories
*/
private function mockResetLimiter(array
$factories): RateLimiter
{ $rateLimiter =
new RateLimiter();
foreach ($factories as $factory =>
$expects) { $limiter =
$this->
createMock(LimiterInterface::
class);
$limiter->
method('consume'
)->
willReturn(new RateLimit(1,
new \
DateTimeImmutable(), true, 1
));
$limiter->
expects($this->
exactly($expects))->
method('reset'
);
$limiterFactory =
$this->
createMock(RateLimiterFactory::
class);
$limiterFactory->
method('create'
)->
willReturn($limiter);
$rateLimiter->
registerLimiterFactory($factory,
$limiterFactory);
}