| 1 | <?php |
||
| 18 | * Class PathTest. |
||
| 19 | */ |
||
| 20 | class PathTest extends \PHPUnit_Framework_TestCase |
||
| 21 | { |
||
| 22 | /** |
||
| 23 | * @var array |
||
| 24 | */ |
||
| 25 | protected $excludedPaths = [ |
||
| 26 | '/user', |
||
| 27 | '/^\/blog\/.+/', |
||
| 28 | ]; |
||
| 29 | |||
| 30 | public function testIsExcludedByString() |
||
| 31 | { |
||
| 32 | $request = ServerRequestFactory::fromGlobals(); |
||
| 33 | $excluder = new Path($this->excludedPaths[0]); |
||
| 34 | |||
| 35 | self::assertTrue($excluder->isExcluded($request->withUri($request->getUri()->withPath('/user')))); |
||
| 36 | } |
||
| 37 | |||
| 38 | public function testIsExcludedByRegex() |
||
| 39 | { |
||
| 40 | $request = ServerRequestFactory::fromGlobals(); |
||
| 41 | $excluder = new Path($this->excludedPaths); |
||
| 42 | |||
| 43 | self::assertTrue($excluder->isExcluded($request->withUri($request->getUri()->withPath('/blog/post')))); |
||
| 44 | } |
||
| 45 | |||
| 46 | public function testIsNotExcluded() |
||
| 47 | { |
||
| 48 | $request = ServerRequestFactory::fromGlobals(); |
||
| 49 | $excluder = new Path($this->excludedPaths); |
||
| 50 | |||
| 51 | self::assertFalse($excluder->isExcluded($request->withUri($request->getUri()->withPath('/home')))); |
||
| 52 | } |
||
| 54 |