| Total Complexity | 5 |
| Total Lines | 80 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | class UrlMatcherTest extends TestCase |
||
| 10 | { |
||
| 11 | private $matcher; |
||
| 12 | |||
| 13 | public function setUp() |
||
| 14 | { |
||
| 15 | $loader = new RouteLoader('tests/fixtures/routing.yml'); |
||
| 16 | $collection = $loader->loadRoutes(); |
||
| 17 | $this->matcher = new UrlMatcher($collection); |
||
| 18 | } |
||
| 19 | |||
| 20 | public function testMatchReturnsCorrectRoute() |
||
| 21 | { |
||
| 22 | $returnBlog = $this->matcher->match('/blog'); |
||
| 23 | $returnSlug = $this->matcher->match('/blog/this-is-a-post'); |
||
| 24 | |||
| 25 | $this->assertEquals( |
||
| 26 | [ |
||
| 27 | 'controller' => 'Blog', |
||
| 28 | 'action' => 'index', |
||
| 29 | 'params' => [] |
||
| 30 | ], |
||
| 31 | $returnBlog |
||
| 32 | ); |
||
| 33 | $this->assertEquals( |
||
| 34 | [ |
||
| 35 | 'controller' => 'Blog', |
||
| 36 | 'action' => 'getPost', |
||
| 37 | 'params' => [ |
||
| 38 | 'slug' => 'this-is-a-post' |
||
| 39 | ] |
||
| 40 | ], |
||
| 41 | $returnSlug |
||
| 42 | ); |
||
| 43 | } |
||
| 44 | |||
| 45 | public function testMatchReturnsDefaultNotFound() |
||
| 46 | { |
||
| 47 | $return= $this->matcher->match('/blogo'); |
||
| 48 | |||
| 49 | $this->assertEquals( |
||
| 50 | [ |
||
| 51 | 'controller' => 'Default', |
||
| 52 | 'action' => 'notFound', |
||
| 53 | 'params' => [] |
||
| 54 | ], |
||
| 55 | $return |
||
| 56 | ); |
||
| 57 | } |
||
| 58 | |||
| 59 | public function testMatchCollectionReturnsWhenFound() |
||
| 81 | ); |
||
| 82 | } |
||
| 83 | |||
| 84 | public function testMatchCollectionDoesNotReturnIfNoMatch() |
||
| 91 |