public function HttpCacheTest::testHitsCachedResponseWithMaxAgeDirective in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/symfony/http-kernel/Tests/HttpCache/HttpCacheTest.php \Symfony\Component\HttpKernel\Tests\HttpCache\HttpCacheTest::testHitsCachedResponseWithMaxAgeDirective()
File
- vendor/
symfony/ http-kernel/ Tests/ HttpCache/ HttpCacheTest.php, line 516
Class
Namespace
Symfony\Component\HttpKernel\Tests\HttpCacheCode
public function testHitsCachedResponseWithMaxAgeDirective() {
$time = \DateTime::createFromFormat('U', time() - 5);
$this
->setNextResponse(200, array(
'Date' => $time
->format(DATE_RFC2822),
'Cache-Control' => 'public, max-age=10',
));
$this
->request('GET', '/');
$this
->assertHttpKernelIsCalled();
$this
->assertEquals(200, $this->response
->getStatusCode());
$this
->assertNotNull($this->response->headers
->get('Date'));
$this
->assertTraceContains('miss');
$this
->assertTraceContains('store');
$this
->assertEquals('Hello World', $this->response
->getContent());
$this
->request('GET', '/');
$this
->assertHttpKernelIsNotCalled();
$this
->assertEquals(200, $this->response
->getStatusCode());
$this
->assertTrue(strtotime($this->responses[0]->headers
->get('Date')) - strtotime($this->response->headers
->get('Date')) < 2);
$this
->assertTrue($this->response->headers
->get('Age') > 0);
$this
->assertNotNull($this->response->headers
->get('X-Content-Digest'));
$this
->assertTraceContains('fresh');
$this
->assertTraceNotContains('store');
$this
->assertEquals('Hello World', $this->response
->getContent());
}