public function StoreTest::testStoresMultipleResponsesForEachVaryCombination

File

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

Class

StoreTest

Namespace

Symfony\Component\HttpKernel\Tests\HttpCache

Code

public function testStoresMultipleResponsesForEachVaryCombination() {
  $req1 = Request::create('/test', 'get', array(), array(), array(), array(
    'HTTP_FOO' => 'Foo',
    'HTTP_BAR' => 'Bar',
  ));
  $res1 = new Response('test 1', 200, array(
    'Vary' => 'Foo Bar',
  ));
  $key = $this->store
    ->write($req1, $res1);
  $req2 = Request::create('/test', 'get', array(), array(), array(), array(
    'HTTP_FOO' => 'Bling',
    'HTTP_BAR' => 'Bam',
  ));
  $res2 = new Response('test 2', 200, array(
    'Vary' => 'Foo Bar',
  ));
  $this->store
    ->write($req2, $res2);
  $req3 = Request::create('/test', 'get', array(), array(), array(), array(
    'HTTP_FOO' => 'Baz',
    'HTTP_BAR' => 'Boom',
  ));
  $res3 = new Response('test 3', 200, array(
    'Vary' => 'Foo Bar',
  ));
  $this->store
    ->write($req3, $res3);
  $this
    ->assertEquals($this
    ->getStorePath('en' . sha1('test 3')), $this->store
    ->lookup($req3)
    ->getContent());
  $this
    ->assertEquals($this
    ->getStorePath('en' . sha1('test 2')), $this->store
    ->lookup($req2)
    ->getContent());
  $this
    ->assertEquals($this
    ->getStorePath('en' . sha1('test 1')), $this->store
    ->lookup($req1)
    ->getContent());
  $this
    ->assertCount(3, $this
    ->getStoreMetadata($key));
}