public function ResponseTest::testIsPrivate

File

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

Class

ResponseTest

Namespace

Symfony\Component\HttpFoundation\Tests

Code

public function testIsPrivate() {
  $response = new Response();
  $response->headers
    ->set('Cache-Control', 'max-age=100');
  $response
    ->setPrivate();
  $this
    ->assertEquals(100, $response->headers
    ->getCacheControlDirective('max-age'), '->isPrivate() adds the private Cache-Control directive when set to true');
  $this
    ->assertTrue($response->headers
    ->getCacheControlDirective('private'), '->isPrivate() adds the private Cache-Control directive when set to true');
  $response = new Response();
  $response->headers
    ->set('Cache-Control', 'public, max-age=100');
  $response
    ->setPrivate();
  $this
    ->assertEquals(100, $response->headers
    ->getCacheControlDirective('max-age'), '->isPrivate() adds the private Cache-Control directive when set to true');
  $this
    ->assertTrue($response->headers
    ->getCacheControlDirective('private'), '->isPrivate() adds the private Cache-Control directive when set to true');
  $this
    ->assertFalse($response->headers
    ->hasCacheControlDirective('public'), '->isPrivate() removes the public Cache-Control directive');
}