/** * @dataProvider providerTestRoutesVariables() * */ public function testRoutesVariables($routePath, $requestUri, $expected) { $manager = new \NickStuer\EasyRouter\RouteManager(); $manager->addRoute(new \NickStuer\EasyRouter\Route('get', $routePath, 'Controller@Method')); $dispatcher = new \NickStuer\EasyRouter\Dispatcher($manager, false, 'get', $requestUri); $data = array(); try { $dispatcher->dispatch(); $routeInfo = $dispatcher->getMatchedRoute(); $data = $routeInfo['variables']; } catch (Exception $ex) { } $this->assertEquals($expected, $data); }
public function testNewRouteManager() { $httpMethod = 'get'; $path = '/test'; $action = 'test@test'; $manager = new \NickStuer\EasyRouter\RouteManager(); $manager->addRoute(new \NickStuer\EasyRouter\Route($httpMethod, $path, $action)); /** * @var \NickStuer\EasyRouter\Route[] $routes */ $routes = $manager->getRoutes(); $this->assertEquals($httpMethod, $routes[0]->getHttpMethod()); $this->assertEquals($path, $routes[0]->getPath()); $this->assertEquals($action, $routes[0]->getAction()); }