public function ResponseTest::testGetVary

File

drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ResponseTest.php, line 271

Class

ResponseTest

Namespace

Symfony\Component\HttpFoundation\Tests

Code

public function testGetVary() {
  $response = new Response();
  $this
    ->assertEquals(array(), $response
    ->getVary(), '->getVary() returns an empty array if no Vary header is present');
  $response = new Response();
  $response->headers
    ->set('Vary', 'Accept-Language');
  $this
    ->assertEquals(array(
    'Accept-Language',
  ), $response
    ->getVary(), '->getVary() parses a single header name value');
  $response = new Response();
  $response->headers
    ->set('Vary', 'Accept-Language User-Agent    X-Foo');
  $this
    ->assertEquals(array(
    'Accept-Language',
    'User-Agent',
    'X-Foo',
  ), $response
    ->getVary(), '->getVary() parses multiple header name values separated by spaces');
  $response = new Response();
  $response->headers
    ->set('Vary', 'Accept-Language,User-Agent,    X-Foo');
  $this
    ->assertEquals(array(
    'Accept-Language',
    'User-Agent',
    'X-Foo',
  ), $response
    ->getVary(), '->getVary() parses multiple header name values separated by commas');
}