public function HttpCacheTest::testEsiCacheSendsTheLowestTtl

File

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

Class

HttpCacheTest

Namespace

Symfony\Component\HttpKernel\Tests\HttpCache

Code

public function testEsiCacheSendsTheLowestTtl() {
  $responses = array(
    array(
      'status' => 200,
      'body' => '<esi:include src="/foo" /> <esi:include src="/bar" />',
      'headers' => array(
        'Cache-Control' => 's-maxage=300',
        'Surrogate-Control' => 'content="ESI/1.0"',
      ),
    ),
    array(
      'status' => 200,
      'body' => 'Hello World!',
      'headers' => array(
        'Cache-Control' => 's-maxage=300',
      ),
    ),
    array(
      'status' => 200,
      'body' => 'My name is Bobby.',
      'headers' => array(
        'Cache-Control' => 's-maxage=100',
      ),
    ),
  );
  $this
    ->setNextResponses($responses);
  $this
    ->request('GET', '/', array(), array(), true);
  $this
    ->assertEquals("Hello World! My name is Bobby.", $this->response
    ->getContent());

  // check for 100 or 99 as the test can be executed after a second change
  $this
    ->assertTrue(in_array($this->response
    ->getTtl(), array(
    99,
    100,
  )));
}