Implementing CakeResponse::disableCache()

This commit is contained in:
José Lorenzo Rodríguez 2010-07-31 17:40:49 -04:30
parent 20d1e483cc
commit 5ba0e43aa3
2 changed files with 22 additions and 1 deletions

View file

@ -493,7 +493,12 @@ class CakeResponse {
* @return void
*/
public function disableCache() {
$this->header(array(
'Expires' => 'Mon, 26 Jul 1997 05:00:00 GMT',
'Last-Modified' => gmdate("D, d M Y H:i:s") . " GMT",
'Cache-Control' => 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0',
'Pragma' => 'no-cache'
));
}
/**

View file

@ -199,4 +199,20 @@ class CakeRequestTestCase extends CakeTestCase {
->method('_sendHeader')->with('Location', 'http://www.example.com');
$response->send();
}
/**
* Tests the disableCache method
*
*/
public function testDisableCache() {
$response = new CakeResponse();
$expected = array(
'Expires' => 'Mon, 26 Jul 1997 05:00:00 GMT',
'Last-Modified' => gmdate("D, d M Y H:i:s") . " GMT",
'Cache-Control' => 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0',
'Pragma' => 'no-cache'
);
$response->disableCache();
$this->assertEquals($response->header(), $expected);
}
}