public function HttpCacheTest::testHitsCachedResponseWithSMaxAgeDirective in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/http-kernel/Tests/HttpCache/HttpCacheTest.php \Symfony\Component\HttpKernel\Tests\HttpCache\HttpCacheTest::testHitsCachedResponseWithSMaxAgeDirective()
File
- vendor/
symfony/ http-kernel/ Tests/ HttpCache/ HttpCacheTest.php, line 540
Class
Namespace
Symfony\Component\HttpKernel\Tests\HttpCacheCode
public function testHitsCachedResponseWithSMaxAgeDirective() {
$time = \DateTime::createFromFormat('U', time() - 5);
$this
->setNextResponse(200, array(
'Date' => $time
->format(DATE_RFC2822),
'Cache-Control' => 's-maxage=10, max-age=0',
));
$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());
}