lithium\tests\cases\action\ResponseTest::testResponseCaching PHP Method

testResponseCaching() public method

public testResponseCaching ( )
    public function testResponseCaching()
    {
        $this->response->body = 'Document body';
        $time = time();
        $expires = strtotime("@{$time} +1 hour");
        $this->response->cache($expires);
        ob_start();
        $this->response->render();
        $result = ob_get_clean();
        $headers = array('HTTP/1.1 200 OK', 'Expires: ' . gmdate('D, d M Y H:i:s', $expires) . ' GMT', 'Cache-Control: max-age=' . ($expires - $time), 'Pragma: cache');
        $this->assertIdentical($headers, $this->response->testHeaders);
        $expires = strtotime("@{$time} +2 hours");
        $this->response->cache($expires);
        ob_start();
        $this->response->render();
        $result = ob_get_clean();
        $headers = array('HTTP/1.1 200 OK', 'Expires: ' . gmdate('D, d M Y H:i:s', $expires) . ' GMT', 'Cache-Control: max-age=' . ($expires - time()), 'Pragma: cache');
        $this->assertIdentical($headers, $this->response->testHeaders);
        $this->response->body = 'Created';
        $this->response->status(201);
        $this->response->cache(false);
        $result = $this->response->headers();
        $expected = array('Expires: Mon, 26 Jul 1997 05:00:00 GMT', 'Cache-Control: no-store, no-cache, must-revalidate', 'Cache-Control: post-check=0, pre-check=0', 'Cache-Control: max-age=0', 'Pragma: no-cache');
        $this->assertIdentical($expected, $result);
        ob_start();
        $this->response->render();
        $result = ob_get_clean();
        $this->assertIdentical('Created', $result);
        $headers = array('HTTP/1.1 201 Created', 'Expires: Mon, 26 Jul 1997 05:00:00 GMT', 'Cache-Control: no-store, no-cache, must-revalidate', 'Cache-Control: post-check=0, pre-check=0', 'Cache-Control: max-age=0', 'Pragma: no-cache');
        $this->assertIdentical($headers, $this->response->testHeaders);
    }