public function testCookieWritingWithEncryption()
{
$inputCookies = array('foo' => 'bar', 'symfony' => 'rocks');
$listener = new EncryptedCookieListener($this->encrypter, array('*'));
$request = Request::create('/');
$response = new Response();
foreach ($inputCookies as $name => $cookie) {
$response->headers->setCookie(new Cookie($name, $cookie));
}
$event = new FilterResponseEvent($this->kernel, $request, HttpKernelInterface::MASTER_REQUEST, $response);
$listener->onKernelResponse($event);
$responseCookieValues = array();
foreach ($response->headers->getCookies() as $cookie) {
$responseCookieValues[$cookie->getName()] = $cookie->getValue();
}
$this->assertNotSame($inputCookies, $responseCookieValues);
$request = Request::create('/', 'GET', array(), $responseCookieValues);
$event = new GetResponseEvent($this->kernel, $request, HttpKernelInterface::MASTER_REQUEST);
$listener->onKernelRequest($event);
$this->assertSame($inputCookies, $request->cookies->all());
}