function testStatusMessage500Sureness() { $request = new Request(); $response = new Response(array('status' => 500)); $response->setContent('The error message'); $msg = $this->SM->getMessage($response, $request); $this->assertContains("The Server has encountered some problems.\nThe error message", $msg, "{$msg} does not contain required full message."); }
function testPassesReturnFromLFactoryToRenderer() { $response = new Response(array('content' => 'response_argument')); $tpl = $this->getMock('Asar\\Template\\TemplateInterface'); $arg = array('template' => $tpl, 'layout' => $tpl, 'mime-type' => 'text/html'); $this->tppRetursTemplates($arg); $this->tsr->expects($this->once())->method('renderTemplate')->with($tpl, $response->getContent(), $tpl); $this->renderer->renderFor('A\\Resource', $response, new Request()); }
function exportResponse(Response $response) { $headers = $response->getHeaders(); foreach ($headers as $key => $value) { $this->header("{$key}: {$value}"); } $this->header("HTTP/1.1 {$response->getStatus()} {$response->getStatusReasonPhrase()}"); echo $response->getContent(); }
function testExportResponseHeadersUsesHeaderFunctionWrapper() { $exporter = $this->getMock('Asar\\ResponseExporter', array('header')); $exporter->expects($this->exactly(3))->method('header'); $exporter->expects($this->at(0))->method('header')->with($this->equalTo('Content-Type: text/plain')); $exporter->expects($this->at(1))->method('header')->with($this->equalTo('Content-Encoding: gzip')); $exporter->expects($this->at(2))->method('header')->with($this->equalTo('HTTP/1.1 404 Not Found')); $response = new Response(); $response->setHeader('Content-Type', 'text/plain'); $response->setHeader('Content-Encoding', 'gzip'); $response->setStatus(404); $exporter->exportResponse($response); }
private function exportRawHttpResponse($raw) { $response = new Response(); $response->import($raw); return $response; }
function handleRequest(RequestInterface $request) { $this->request = $request; $response = new Response(array('headers' => array('Content-Type' => $this->getConfig('default_content_type'), 'Content-Language' => $this->getConfig('default_language')))); try { if (!$this->qualify($this->getPathComponents())) { throw new NotFound(); } $response->setContent($this->runIfExists($request->getMethod())); } catch (NotFound $e) { $response->setStatus(404); } catch (MethodUndefined $e) { $response->setStatus(405); $response->setHeader('Allow', $this->getDefinedMethods()); } catch (Redirect $e) { $payload = $e->getPayload(); $response->setStatus($payload['status_code']); $response->setHeader('Location', $payload['location']); if (isset($payload['locations_list'])) { $response->setHeader('Asar-Internal-Locationslist', $payload['locations_list']); } } catch (ForwardRequest $e) { throw $e; } catch (\Exception $e) { $response->setStatus(500); $response->setContent($e->getMessage()); } return $response; }