public function HttpCacheTest::testStoresMultipleResponsesWhenHeadersDiffer 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::testStoresMultipleResponsesWhenHeadersDiffer()
File
- vendor/
symfony/ http-kernel/ Tests/ HttpCache/ HttpCacheTest.php, line 975
Class
Namespace
Symfony\Component\HttpKernel\Tests\HttpCacheCode
public function testStoresMultipleResponsesWhenHeadersDiffer() {
$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
->assertEquals(1, $this->response->headers
->get('X-Response-Count'));
$this
->request('GET', '/', array(
'HTTP_ACCEPT' => 'text/html',
'HTTP_USER_AGENT' => 'Bob/2.0',
));
$this
->assertEquals(200, $this->response
->getStatusCode());
$this
->assertTraceContains('miss');
$this
->assertTraceContains('store');
$this
->assertEquals('Bob/2.0', $this->response
->getContent());
$this
->assertEquals(2, $this->response->headers
->get('X-Response-Count'));
$this
->request('GET', '/', array(
'HTTP_ACCEPT' => 'text/html',
'HTTP_USER_AGENT' => 'Bob/1.0',
));
$this
->assertTraceContains('fresh');
$this
->assertEquals('Bob/1.0', $this->response
->getContent());
$this
->assertEquals(1, $this->response->headers
->get('X-Response-Count'));
$this
->request('GET', '/', array(
'HTTP_ACCEPT' => 'text/html',
'HTTP_USER_AGENT' => 'Bob/2.0',
));
$this
->assertTraceContains('fresh');
$this
->assertEquals('Bob/2.0', $this->response
->getContent());
$this
->assertEquals(2, $this->response->headers
->get('X-Response-Count'));
$this
->request('GET', '/', array(
'HTTP_USER_AGENT' => 'Bob/2.0',
));
$this
->assertTraceContains('miss');
$this
->assertEquals('Bob/2.0', $this->response
->getContent());
$this
->assertEquals(3, $this->response->headers
->get('X-Response-Count'));
}