public function dispatchHttp() { if (!$this->config['action_controller']['error_handler']) { if ($this->config['environment'] == 'production') { } } $dispatcher = new ActionDispatch($this); $dispatcher->dispatch($this->request()->method(), $this->request()->path()); // $this->response()->commit(); // $this->getService('log')->setRequest($this->request()); // $routeParams = $this->routes()->match( // $this->request()->path(), // $this->request()->method() // ); // if (!$routeParams) { // # Route not found. // throw new \Rails\Routing\Exception\NotFoundException( // sprintf( // 'No route matches [%s] "%s"', // $this->request()->method(), // $this->request()->path() // ) // ); // } // list ($route, $routeVars) = $routeParams; // if ($route->controller() == ':controller') { // $route->setProperController( // lcfirst($this->getService('inflector') // ->camelize($routeVars['controller'])->toString()) // ); // } // if ($route->action() == ':action') { // $route->setProperAction( // lcfirst($this->getService('inflector') // ->camelize($routeVars['action'])->toString()) // ); // } // $this->parameters()->setRouteVars($routeVars); // ActionToken::setRoute($route); // $this->routes()->setRequestRoute($route); // $this->request()->setRequestRoute($route); // $endPoint = $route->endPoint(); // call_user_func( // $endPoint, // $this // ); // $this->response()->commit(); }
public function runAction($method, $actionName, array $customParams = [], array $session = []) { $controllerClass = $this->resolveControllerClass(); $path = $this->ensureRouteExists($controllerClass, $actionName, $customParams); $response = new TestResponse(); $this->parameters->reset(); $this->setCustomRequestParams($this->parameters, $method, $customParams); $appClone = clone $this->application(); $appRefl = new ReflectionClass(get_class($appClone)); $response->setCookieJar($this->request->cookieJar()); $this->request->resetUploadedFiles($customParams); foreach (['request', 'parameters', 'session', 'response'] as $propName) { $prop = $appRefl->getProperty($propName); $prop->setAccessible(true); $value = $propName == 'response' ? $response : $this->{$propName}; $prop->setValue($appClone, $value); } $this->cookies = $response->cookieJar(); $dispatcher = new ActionDispatch($appClone); $endPoint = $dispatcher->dispatch($method, $path); $this->controller = $endPoint->controller(); }