You are here

public function HttpCacheTest::testDoesNotRevalidateFreshCacheEntryWhenEnableRevalidateOptionIsSetFalseDefault in Zircon Profile 8.0

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

File

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

Class

HttpCacheTest

Namespace

Symfony\Component\HttpKernel\Tests\HttpCache

Code

public function testDoesNotRevalidateFreshCacheEntryWhenEnableRevalidateOptionIsSetFalseDefault() {
  $count = 0;
  $this
    ->setNextResponse(200, array(), '', function ($request, $response) use (&$count) {
    ++$count;
    $response->headers
      ->set('Cache-Control', 'public, max-age=10000');
    $response
      ->setETag($count);
    $response
      ->setContent(1 == $count ? 'Hello World' : 'Goodbye World');
  });
  $this
    ->request('GET', '/');
  $this
    ->assertEquals(200, $this->response
    ->getStatusCode());
  $this
    ->assertEquals('Hello World', $this->response
    ->getContent());
  $this
    ->assertTraceContains('store');
  $this
    ->request('GET', '/');
  $this
    ->assertEquals(200, $this->response
    ->getStatusCode());
  $this
    ->assertEquals('Hello World', $this->response
    ->getContent());
  $this
    ->assertTraceContains('fresh');
  $this->cacheConfig['allow_revalidate'] = false;
  $this
    ->request('GET', '/', array(
    'HTTP_CACHE_CONTROL' => 'max-age=0',
  ));
  $this
    ->assertEquals(200, $this->response
    ->getStatusCode());
  $this
    ->assertEquals('Hello World', $this->response
    ->getContent());
  $this
    ->assertTraceNotContains('stale');
  $this
    ->assertTraceNotContains('invalid');
  $this
    ->assertTraceContains('fresh');
  $this
    ->request('GET', '/', array(
    'HTTP_CACHE_CONTROL' => 'max-age=0',
  ));
  $this
    ->assertEquals(200, $this->response
    ->getStatusCode());
  $this
    ->assertEquals('Hello World', $this->response
    ->getContent());
  $this
    ->assertTraceNotContains('stale');
  $this
    ->assertTraceNotContains('invalid');
  $this
    ->assertTraceContains('fresh');
}