You are here

public function ResponseHeaderBagTest::testCookiesWithSameNames in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/http-foundation/Tests/ResponseHeaderBagTest.php \Symfony\Component\HttpFoundation\Tests\ResponseHeaderBagTest::testCookiesWithSameNames()

File

vendor/symfony/http-foundation/Tests/ResponseHeaderBagTest.php, line 168

Class

ResponseHeaderBagTest

Namespace

Symfony\Component\HttpFoundation\Tests

Code

public function testCookiesWithSameNames() {
  $bag = new ResponseHeaderBag();
  $bag
    ->setCookie(new Cookie('foo', 'bar', 0, '/path/foo', 'foo.bar'));
  $bag
    ->setCookie(new Cookie('foo', 'bar', 0, '/path/bar', 'foo.bar'));
  $bag
    ->setCookie(new Cookie('foo', 'bar', 0, '/path/bar', 'bar.foo'));
  $bag
    ->setCookie(new Cookie('foo', 'bar'));
  $this
    ->assertCount(4, $bag
    ->getCookies());
  $headers = explode("\r\n", $bag
    ->__toString());
  $this
    ->assertContains('Set-Cookie: foo=bar; path=/path/foo; domain=foo.bar; httponly', $headers);
  $this
    ->assertContains('Set-Cookie: foo=bar; path=/path/foo; domain=foo.bar; httponly', $headers);
  $this
    ->assertContains('Set-Cookie: foo=bar; path=/path/bar; domain=bar.foo; httponly', $headers);
  $this
    ->assertContains('Set-Cookie: foo=bar; path=/; httponly', $headers);
  $cookies = $bag
    ->getCookies(ResponseHeaderBag::COOKIES_ARRAY);
  $this
    ->assertTrue(isset($cookies['foo.bar']['/path/foo']['foo']));
  $this
    ->assertTrue(isset($cookies['foo.bar']['/path/bar']['foo']));
  $this
    ->assertTrue(isset($cookies['bar.foo']['/path/bar']['foo']));
  $this
    ->assertTrue(isset($cookies['']['/']['foo']));
}