public function HttpCacheTest::testServesFromCacheWhenHeadersMatch 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::testServesFromCacheWhenHeadersMatch()
File
- vendor/
symfony/ http-kernel/ Tests/ HttpCache/ HttpCacheTest.php, line 951
Class
Namespace
Symfony\Component\HttpKernel\Tests\HttpCacheCode
public function testServesFromCacheWhenHeadersMatch() {
$count = 0;
$this
->setNextResponse(200, array(
'Cache-Control' => 'max-age=10000',
), '', function ($request, $response) use (&$count) {
$response->headers
->set('Vary', 'Accept User-Agent Foo');
$response->headers
->set('Cache-Control', 'public, max-age=10');
$response->headers
->set('X-Response-Count', ++$count);
$response
->setContent($request->headers
->get('USER_AGENT'));
});
$this
->request('GET', '/', array(
'HTTP_ACCEPT' => 'text/html',
'HTTP_USER_AGENT' => 'Bob/1.0',
));
$this
->assertEquals(200, $this->response
->getStatusCode());
$this
->assertEquals('Bob/1.0', $this->response
->getContent());
$this
->assertTraceContains('miss');
$this
->assertTraceContains('store');
$this
->request('GET', '/', array(
'HTTP_ACCEPT' => 'text/html',
'HTTP_USER_AGENT' => 'Bob/1.0',
));
$this
->assertEquals(200, $this->response
->getStatusCode());
$this
->assertEquals('Bob/1.0', $this->response
->getContent());
$this
->assertTraceContains('fresh');
$this
->assertTraceNotContains('store');
$this
->assertNotNull($this->response->headers
->get('X-Content-Digest'));
}