function testCacheControlRespected() { $this->request->mock(); $this->response->html("Hello"); $this->response->getCacheControl()->makePublic(); $this->assertEquals("Hello", $this->send()); $expected = array("HTTP/1.1 200 OK", "Content-Type: text/html", "Date: " . $this->response->getHeader("Date"), "Cache-Control: public", "Content-Length: 5"); $this->assertEquals($expected, HeaderStack::stack()); }
/** * Provides a minimal default not found response, emitting a HTTP Status 404 * and writing "Not Found" to the User Agent. * * @param Request $request * @param Response $response * @return void */ public function defaultNotFound(Request $request, Response $response) { $response->html("<b>Not Found</b>", 404); }
function testHtml() { $response = new Response(); $response->html("ABC"); $this->assertEquals(200, $response->getStatus()); $this->assertEquals("ABC", $response->getBody()); $this->assertEquals("text/html", $response->getHeader("Content-Type")); $response->html("DEF", 404, array("Content-Type" => "text/xhtml")); $this->assertEquals(404, $response->getStatus()); $this->assertEquals("DEF", $response->getBody()); $this->assertEquals("text/xhtml", $response->getHeader("Content-Type")); }