|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the Symfony package. |
| 5 | + * |
| 6 | + * (c) Fabien Potencier <fabien@symfony.com> |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
| 12 | +namespace Symfony\Component\RateLimiter\Tests; |
| 13 | + |
| 14 | +use PHPUnit\Framework\TestCase; |
| 15 | +use Symfony\Component\RateLimiter\CompoundLimiter; |
| 16 | +use Symfony\Component\RateLimiter\LimiterInterface; |
| 17 | +use Symfony\Component\RateLimiter\Policy\FixedWindowLimiter; |
| 18 | +use Symfony\Component\RateLimiter\Policy\NoLimiter; |
| 19 | +use Symfony\Component\RateLimiter\Policy\Rate; |
| 20 | +use Symfony\Component\RateLimiter\Policy\SlidingWindowLimiter; |
| 21 | +use Symfony\Component\RateLimiter\Policy\TokenBucketLimiter; |
| 22 | +use Symfony\Component\RateLimiter\RateLimiterBuilder; |
| 23 | +use Symfony\Component\RateLimiter\Storage\InMemoryStorage; |
| 24 | + |
| 25 | +class RateLimiterBuilderTest extends TestCase |
| 26 | +{ |
| 27 | + public function testCreateMethods() |
| 28 | + { |
| 29 | + $builder = new RateLimiterBuilder(new InMemoryStorage()); |
| 30 | + |
| 31 | + $this->assertInstanceOf(SlidingWindowLimiter::class, $builder->slidingWindow('foo', 5, '1 minute')); |
| 32 | + $this->assertInstanceOf(FixedWindowLimiter::class, $builder->fixedWindow('foo', 5, '1 minute')); |
| 33 | + $this->assertInstanceOf(TokenBucketLimiter::class, $builder->tokenBucket('foo', 5, Rate::perHour(2))); |
| 34 | + $this->assertInstanceOf(CompoundLimiter::class, $builder->compound($this->createMock(LimiterInterface::class))); |
| 35 | + $this->assertInstanceOf(NoLimiter::class, $builder->noop()); |
| 36 | + } |
| 37 | +} |
0 commit comments