Skip to content
Permalink
Browse files

Adding test case for maxAge()

  • Loading branch information...
lorenzo committed Nov 7, 2011
1 parent d9987c9 commit 2428e83e3f18f3ab878df5f6bc61b679efcc80fc
Showing with 31 additions and 0 deletions.
  1. +31 −0 lib/Cake/Test/Case/Network/CakeResponseTest.php
@@ -636,6 +636,11 @@ public function testModified() {
$response->send();
}
/**
* Tests setting of public/private Cache-Control directives
*
* @return void
*/
public function testSharable() {
$response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent'));
$this->assertNull($response->sharable());
@@ -669,4 +674,30 @@ public function testSharable() {
$response->sharable(true);
$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();
}
}

0 comments on commit 2428e83

Please sign in to comment.
You can’t perform that action at this time.