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