MockAbstractRequestRateLimiter example

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\RateLimiter\LimiterInterface;
use Symfony\Component\RateLimiter\RateLimit;

class AbstractRequestRateLimiterTest extends TestCase
{
    /** * @dataProvider provideRateLimits */
    public function testConsume(array $rateLimits, ?RateLimit $expected)
    {
        $rateLimiter = new MockAbstractRequestRateLimiter(array_map(function DRateLimit $rateLimit) {
            $limiter = $this->createStub(LimiterInterface::class);
            $limiter->method('consume')->willReturn($rateLimit);

            return $limiter;
        }$rateLimits));

        $this->assertSame($expected$rateLimiter->consume(new Request()));
    }

    public static function provideRateLimits()
    {
        
Home | Imprint | This part of the site doesn't use cookies.