You are here

public function ClientTest::testFilterResponseConvertsCookies in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/http-kernel/Tests/ClientTest.php \Symfony\Component\HttpKernel\Tests\ClientTest::testFilterResponseConvertsCookies()

File

vendor/symfony/http-kernel/Tests/ClientTest.php, line 51

Class

ClientTest

Namespace

Symfony\Component\HttpKernel\Tests

Code

public function testFilterResponseConvertsCookies() {
  $client = new Client(new TestHttpKernel());
  $r = new \ReflectionObject($client);
  $m = $r
    ->getMethod('filterResponse');
  $m
    ->setAccessible(true);
  $expected = array(
    'foo=bar; expires=Sun, 15 Feb 2009 20:00:00 GMT; domain=http://example.com; path=/foo; secure; httponly',
    'foo1=bar1; expires=Sun, 15 Feb 2009 20:00:00 GMT; domain=http://example.com; path=/foo; secure; httponly',
  );
  $response = new Response();
  $response->headers
    ->setCookie(new Cookie('foo', 'bar', \DateTime::createFromFormat('j-M-Y H:i:s T', '15-Feb-2009 20:00:00 GMT')
    ->format('U'), '/foo', 'http://example.com', true, true));
  $domResponse = $m
    ->invoke($client, $response);
  $this
    ->assertEquals($expected[0], $domResponse
    ->getHeader('Set-Cookie'));
  $response = new Response();
  $response->headers
    ->setCookie(new Cookie('foo', 'bar', \DateTime::createFromFormat('j-M-Y H:i:s T', '15-Feb-2009 20:00:00 GMT')
    ->format('U'), '/foo', 'http://example.com', true, true));
  $response->headers
    ->setCookie(new Cookie('foo1', 'bar1', \DateTime::createFromFormat('j-M-Y H:i:s T', '15-Feb-2009 20:00:00 GMT')
    ->format('U'), '/foo', 'http://example.com', true, true));
  $domResponse = $m
    ->invoke($client, $response);
  $this
    ->assertEquals($expected[0], $domResponse
    ->getHeader('Set-Cookie'));
  $this
    ->assertEquals($expected, $domResponse
    ->getHeader('Set-Cookie', false));
}