public function testResponseRendering() {
$this->response->body = 'Document body';
ob_start();
$this->response->render();
$result = ob_get_clean();
$this->assertEqual('Document body', $result);
$this->assertEqual(array('HTTP/1.1 200 OK'), $this->response->testHeaders);
ob_start();
echo $this->response;
$result = ob_get_clean();
$this->assertEqual('Document body', $result);
$this->assertEqual(array('HTTP/1.1 200 OK'), $this->response->testHeaders);
$expires = strtotime('+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->assertEqual($headers, $this->response->testHeaders);
$expires = '+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', strtotime($expires)) . ' GMT',
'Cache-Control: max-age=' . (strtotime($expires) - time()),
'Pragma: cache'
);
$this->assertEqual($headers, $this->response->testHeaders);
$this->response->body = 'Created';
$this->response->status(201);
$this->response->cache(false);
ob_start();
$this->response->render();
$result = ob_get_clean();
$this->assertEqual('Created', $result);
$headers = array (
'HTTP/1.1 201 Created',
'Expires: Mon, 26 Jul 1997 05:00:00 GMT',
array(
'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->assertEqual($headers, $this->response->testHeaders);
$this->expectException('/^`Request::disableCache\(\)`.+`Request::cache\(false\)`/');
$this->response->disableCache();
}