$response =
new Response( 'Response content.',
202,
[ 'X-Symfony' =>
['3.4'
],
' X-Broken-Header' => 'abc',
] );
$response->headers->
setCookie(new Cookie('city', 'Lille',
new \
DateTime('Wed, 13 Jan 2021 22:23:01 GMT'
), '/', null, false, true, false, 'lax'
));
$psrResponse =
$factory->
createResponse($response);
$this->
assertSame('Response content.',
$psrResponse->
getBody()->
__toString());
$this->
assertSame(202,
$psrResponse->
getStatusCode());
$this->
assertSame(['3.4'
],
$psrResponse->
getHeader('x-symfony'
));
$this->
assertFalse($psrResponse->
hasHeader(' X-Broken-Header'
));
$this->
assertFalse($psrResponse->
hasHeader('X-Broken-Header'
));
$cookieHeader =
$psrResponse->
getHeader('Set-Cookie'
);
$this->
assertIsArray($cookieHeader);
$this->
assertCount(1,
$cookieHeader);
$this->
assertMatchesRegularExpression('{city=Lille; expires=Wed, 13.Jan.2021 22:23:01 GMT;( max-age=\d+;)? path=/; httponly}i',
$cookieHeader[0
]);
}