Skip to content

Commit

Permalink
Adding test case for maxAge()
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Jan 19, 2012
1 parent d9987c9 commit 2428e83
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions lib/Cake/Test/Case/Network/CakeResponseTest.php
Expand Up @@ -636,6 +636,11 @@ public function testModified() {
$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());
Expand Down Expand Up @@ -669,4 +674,30 @@ public function testSharable() {
$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();
}
} }

0 comments on commit 2428e83

Please sign in to comment.