mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 11:06:15 +00:00
Adding test case for maxAge()
This commit is contained in:
parent
d9987c96db
commit
2428e83e3f
1 changed files with 31 additions and 0 deletions
|
@ -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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue