/** * Try to Route It - As it sounds like, works with the router to * match a route against the current URI. If the route is a * "redirect route", will also handle the redirect. * * @param RouteCollectionInterface $routes An collection interface to use in place * of the config file. */ protected function tryToRouteIt(RouteCollectionInterface $routes = null) { if (empty($routes) || !$routes instanceof RouteCollectionInterface) { require APPPATH . 'Config/Routes.php'; } // $routes is defined in Config/Routes.php $this->router = Services::router($routes); $path = is_cli() ? $this->request->getPath() : $this->request->uri->getPath(); $this->benchmark->stop('bootstrap'); $this->benchmark->start('routing'); ob_start(); $this->controller = $this->router->handle($path); $this->method = $this->router->methodName(); $this->benchmark->stop('routing'); }
public function testClosures() { $router = new Router($this->collection); $router->handle('closure/123/alpha'); $closure = $router->controllerName(); $expects = call_user_func_array($closure, $router->params()); $this->assertTrue(is_callable($router->controllerName())); $this->assertEquals($expects, '123-alpha'); }