| 1 | <?php |
||
| 18 | * Class HeaderTest. |
||
| 19 | */ |
||
| 20 | class HeaderTest extends \PHPUnit_Framework_TestCase |
||
| 21 | { |
||
| 22 | public function testIsExcludedExists() |
||
| 23 | { |
||
| 24 | $request = ServerRequestFactory::fromGlobals(); |
||
| 25 | $excluder = new Header('X-Custom-Header'); |
||
| 26 | |||
| 27 | self::assertTrue($excluder->isExcluded($request->withHeader('X-Custom-Header', ''))); |
||
| 28 | } |
||
| 29 | |||
| 30 | public function testIsExcludedByString() |
||
| 31 | { |
||
| 32 | $request = ServerRequestFactory::fromGlobals(); |
||
| 33 | $excluder = new Header('X-Custom-Header', 'my-value'); |
||
| 34 | |||
| 35 | self::assertTrue($excluder->isExcluded($request->withHeader('X-Custom-Header', 'my-value'))); |
||
| 36 | } |
||
| 37 | |||
| 38 | public function testIsExcludedByRegex() |
||
| 39 | { |
||
| 40 | $request = ServerRequestFactory::fromGlobals(); |
||
| 41 | $excluder = new Header('X-Custom-Header', '/^my/'); |
||
| 42 | |||
| 43 | self::assertTrue($excluder->isExcluded($request->withHeader('X-Custom-Header', 'my-value'))); |
||
| 44 | } |
||
| 45 | |||
| 46 | public function testIsNotExcluded() |
||
| 47 | { |
||
| 48 | $excluder = new Header('X-Custom-Header'); |
||
| 49 | |||
| 50 | self::assertFalse($excluder->isExcluded(ServerRequestFactory::fromGlobals())); |
||
| 51 | } |
||
| 53 |