You are here

public function HttpCacheTest::testSendsNoContentWhenFresh in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/http-kernel/Tests/HttpCache/HttpCacheTest.php \Symfony\Component\HttpKernel\Tests\HttpCache\HttpCacheTest::testSendsNoContentWhenFresh()

File

vendor/symfony/http-kernel/Tests/HttpCache/HttpCacheTest.php, line 884

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());
}