|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the SeoOverride project. |
| 5 | + * |
| 6 | + * (c) JoliCode <[email protected]> |
| 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 Joli\SeoOverride\Tests\Unit\Bridge\Symfony\Blacklister; |
| 13 | + |
| 14 | +use Joli\SeoOverride\Bridge\Symfony\Blacklister\NotMethodBlacklister; |
| 15 | +use PHPUnit\Framework\TestCase; |
| 16 | +use Symfony\Component\HttpFoundation\Request; |
| 17 | +use Symfony\Component\HttpFoundation\Response; |
| 18 | + |
| 19 | +class NotMethodBlacklisterTest extends TestCase |
| 20 | +{ |
| 21 | + /** @var NotMethodBlacklisterTest */ |
| 22 | + private $blacklister; |
| 23 | + |
| 24 | + public function setUp() |
| 25 | + { |
| 26 | + parent::setUp(); |
| 27 | + } |
| 28 | + |
| 29 | + public function test_it_blacklists_not_accepted_method_requests() |
| 30 | + { |
| 31 | + $request = new Request(); |
| 32 | + $request->setMethod('put'); |
| 33 | + |
| 34 | + $blacklister = new NotMethodBlacklister(['GET', 'POST']); |
| 35 | + |
| 36 | + self::assertTrue($blacklister->isBlacklisted($request, new Response())); |
| 37 | + } |
| 38 | + |
| 39 | + public function test_it_does_not_blacklist_accepted_method_requests() |
| 40 | + { |
| 41 | + $request = new Request(); |
| 42 | + $request->setMethod('get'); |
| 43 | + |
| 44 | + $blacklister = new NotMethodBlacklister('GET'); |
| 45 | + |
| 46 | + self::assertFalse($blacklister->isBlacklisted($request, new Response())); |
| 47 | + |
| 48 | + $request = new Request(); |
| 49 | + $request->setMethod('get'); |
| 50 | + |
| 51 | + $blacklister = new NotMethodBlacklister(['GET', 'POST']); |
| 52 | + |
| 53 | + self::assertFalse($blacklister->isBlacklisted($request, new Response())); |
| 54 | + |
| 55 | + $request = new Request(); |
| 56 | + $request->setMethod('POST'); |
| 57 | + |
| 58 | + $blacklister = new NotMethodBlacklister(['GET', 'POST']); |
| 59 | + |
| 60 | + self::assertFalse($blacklister->isBlacklisted($request, new Response())); |
| 61 | + } |
| 62 | +} |
0 commit comments