public function HttpCacheTest::testSendsNoContentWhenFresh

File

drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php, line 798

Class

HttpCacheTest

Namespace

Symfony\Component\HttpKernel\Tests\HttpCache

Code

public function testSendsNoContentWhenFresh() {
  $time = \DateTime::createFromFormat('U', time());
  $that = $this;
  $this
    ->setNextResponse(200, array(), 'Hello World', function ($request, $response) use ($that, $time) {
    $response->headers
      ->set('Cache-Control', 'public, max-age=10');
    $response->headers
      ->set('Last-Modified', $time
      ->format(DATE_RFC2822));
  });
  $this
    ->request('GET', '/');
  $this
    ->assertHttpKernelIsCalled();
  $this
    ->assertEquals('Hello World', $this->response
    ->getContent());
  $this
    ->request('GET', '/', array(
    'HTTP_IF_MODIFIED_SINCE' => $time
      ->format(DATE_RFC2822),
  ));
  $this
    ->assertHttpKernelIsNotCalled();
  $this
    ->assertEquals(304, $this->response
    ->getStatusCode());
  $this
    ->assertEquals('', $this->response
    ->getContent());
}