public function testMultiRenderResponse() { $output = ''; $this->response->addEventHandler(Response::OUTPUT_EVENT, function (Response $response) use(&$output) { $output .= $response->getResponse(); }); $this->response->setResponseType(Response::TEXT); $this->response->setResponse('Hello World '); $this->response->render(); $this->response->setResponse('Lili is the best'); $this->response->render(); $this->assertSame('Hello World Lili is the best', $output); }
private function routeRequest(Request $request, Service $service) { $desired_method = String::underscoreToCamelCase($request->getMethod()); $requested_method = $request->getRequestMethod() . $desired_method; $method = $requested_method; $arguments = $request->getArguments(); if (!method_exists($service, $method)) { $method = $request->getRequestMethod() . 'Router'; if (!method_exists($service, $method)) { throw new MethodNotSupported($request->getService(), $requested_method); } array_splice($arguments, 0, 0, array($request->getMethod())); } $output = call_user_func_array(array($service, $method), $arguments); $this->response->setResponse($output); }