public function StoreTest::testOverwritesNonVaryingResponseWithStore

File

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

Class

StoreTest

Namespace

Symfony\Component\HttpKernel\Tests\HttpCache

Code

public function testOverwritesNonVaryingResponseWithStore() {
  $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);
  $this
    ->assertEquals($this
    ->getStorePath('en' . sha1('test 1')), $this->store
    ->lookup($req1)
    ->getContent());
  $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);
  $this
    ->assertEquals($this
    ->getStorePath('en' . sha1('test 2')), $this->store
    ->lookup($req2)
    ->getContent());
  $req3 = Request::create('/test', 'get', array(), array(), array(), array(
    'HTTP_FOO' => 'Foo',
    'HTTP_BAR' => 'Bar',
  ));
  $res3 = new Response('test 3', 200, array(
    'Vary' => 'Foo Bar',
  ));
  $key = $this->store
    ->write($req3, $res3);
  $this
    ->assertEquals($this
    ->getStorePath('en' . sha1('test 3')), $this->store
    ->lookup($req3)
    ->getContent());
  $this
    ->assertCount(2, $this
    ->getStoreMetadata($key));
}