'Data', 'action' => 'index'], '', ['controller' => 'Data', 'action' => 'index'] ], [ '{controller}/{action}', [], 'posts/new', ['controller' => 'posts', 'action' => 'new'] ], [ '{controller}/{id:\d+}/{action}', [], 'posts/3/edit', ['controller' => 'posts', 'action' => 'edit', 'id' => '3'] ] ]; } /** * * @test * @dataProvider routeProvider */ public function matchingRouteSuccess($route, $params, $url, $expected_param) { $router = new Router(); $router->add($route, $params); $this->assertTrue($router->match($url)); $this->assertEquals($expected_param, $router->getParams()); } /** * * @test */ public function dispatchingRouteSuccess() { $url = 'posts/113/edit'; $router = new Router(); $router->add('{controller}/{id:\d+}/{action}'); // $router->add($route, $params); $this->assertTrue($router->match($url)); $this->assertTrue($router->dispatch($url)); } }