You are here

public function HttpCacheTest::testUsesCacheToRespondToHeadRequestsWhenFresh 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::testUsesCacheToRespondToHeadRequestsWhenFresh()

File

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

Class

HttpCacheTest

Namespace

Symfony\Component\HttpKernel\Tests\HttpCache

Code

public function testUsesCacheToRespondToHeadRequestsWhenFresh() {
  $that = $this;
  $this
    ->setNextResponse(200, array(), 'Hello World', function ($request, $response) use ($that) {
    $response->headers
      ->set('Cache-Control', 'public, max-age=10');
    $response
      ->setContent('Hello World');
    $response
      ->setStatusCode(200);
    $that
      ->assertNotEquals('HEAD', $request
      ->getMethod());
  });
  $this
    ->request('GET', '/');
  $this
    ->assertHttpKernelIsCalled();
  $this
    ->assertEquals('Hello World', $this->response
    ->getContent());
  $this
    ->request('HEAD', '/');
  $this
    ->assertHttpKernelIsNotCalled();
  $this
    ->assertEquals(200, $this->response
    ->getStatusCode());
  $this
    ->assertEquals('', $this->response
    ->getContent());
  $this
    ->assertEquals(strlen('Hello World'), $this->response->headers
    ->get('Content-Length'));
}