From 2428e83e3f18f3ab878df5f6bc61b679efcc80fc Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Sun, 6 Nov 2011 23:58:09 -0430 Subject: [PATCH] Adding test case for maxAge() --- .../Test/Case/Network/CakeResponseTest.php | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/lib/Cake/Test/Case/Network/CakeResponseTest.php b/lib/Cake/Test/Case/Network/CakeResponseTest.php index d39ff8982..03c58f6ec 100644 --- a/lib/Cake/Test/Case/Network/CakeResponseTest.php +++ b/lib/Cake/Test/Case/Network/CakeResponseTest.php @@ -636,6 +636,11 @@ class CakeResponseTest extends CakeTestCase { $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 @@ class CakeResponseTest extends CakeTestCase { $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(); + } }