public function ResponseTest::testGetMaxAge in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/http-foundation/Tests/ResponseTest.php \Symfony\Component\HttpFoundation\Tests\ResponseTest::testGetMaxAge()
File
- vendor/
symfony/ http-foundation/ Tests/ ResponseTest.php, line 278
Class
Namespace
Symfony\Component\HttpFoundation\TestsCode
public function testGetMaxAge() {
$response = new Response();
$response->headers
->set('Cache-Control', 's-maxage=600, max-age=0');
$this
->assertEquals(600, $response
->getMaxAge(), '->getMaxAge() uses s-maxage cache control directive when present');
$response = new Response();
$response->headers
->set('Cache-Control', 'max-age=600');
$this
->assertEquals(600, $response
->getMaxAge(), '->getMaxAge() falls back to max-age when no s-maxage directive present');
$response = new Response();
$response->headers
->set('Cache-Control', 'must-revalidate');
$response->headers
->set('Expires', $this
->createDateTimeOneHourLater()
->format(DATE_RFC2822));
$this
->assertLessThanOrEqual(1, $response
->getMaxAge() - 3600, '->getMaxAge() falls back to Expires when no max-age or s-maxage directive present');
$response = new Response();
$response->headers
->set('Cache-Control', 'must-revalidate');
$response->headers
->set('Expires', -1);
$this
->assertEquals('Sat, 01 Jan 00 00:00:00 +0000', $response
->getExpires()
->format(DATE_RFC822));
$response = new Response();
$this
->assertNull($response
->getMaxAge(), '->getMaxAge() returns null if no freshness information available');
}