Adding test case for maxAge()

This commit is contained in:
Jose Lorenzo Rodriguez 2011-11-06 23:58:09 -04:30
parent d9987c96db
commit 2428e83e3f

View file

@ -636,6 +636,11 @@ class CakeResponseTest extends CakeTestCase {
$response->send(); $response->send();
} }
/**
* Tests setting of public/private Cache-Control directives
*
* @return void
*/
public function testSharable() { public function testSharable() {
$response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent')); $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent'));
$this->assertNull($response->sharable()); $this->assertNull($response->sharable());
@ -669,4 +674,30 @@ class CakeResponseTest extends CakeTestCase {
$response->sharable(true); $response->sharable(true);
$this->assertTrue($response->sharable()); $this->assertTrue($response->sharable());
} }
/**
* Tests setting of max-age Cache-Control directive
*
* @return void
*/
public function testMaxAge() {
$response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent'));
$this->assertNull($response->maxAge());
$response->maxAge(3600);
$this->assertEquals(3600, $response->maxAge());
$headers = $response->header();
$this->assertEquals('max-age=3600', $headers['Cache-Control']);
$response->expects($this->at(1))
->method('_sendHeader')->with('Cache-Control', 'max-age=3600');
$response->send();
$response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent'));
$response->maxAge(3600);
$response->sharable(true);
$headers = $response->header();
$this->assertEquals('max-age=3600, public', $headers['Cache-Control']);
$response->expects($this->at(1))
->method('_sendHeader')->with('Cache-Control', 'max-age=3600, public');
$response->send();
}
} }