/** * Dispatches a Route. * * @param Route $route * @return mixed Dispatched route return value, if any */ public function dispatch(Route $route) { $this->beforeStart(); return $this->router->dispatch($route, $this->request); }
public function testCreateRedirect() { // Prepare: Prepare environment to capture response $response = new Response(); $request = new Request(); $request->setRequestUri('/redirect/bla'); $context = new Context(); $context->registerInstance($response); $context->registerInstance($request); $router = new Router(); $router->setContext($context); $route = $router->createRedirect('/redirect/$testVar', '/target/$testVar', true); $this->assertEquals('/redirect/$testVar', $route->getPattern()); $routeResult = $router->route($request); $this->assertEquals($route, $routeResult); $router->dispatch($routeResult, $request); $this->assertEquals(ResponseCode::HTTP_MOVED_PERMANENTLY, $response->getResponseCode()); $this->assertEquals('/target/bla', $response->getHeader('Location')); }