use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
use Symfony\Component\Security\Http\Event\LogoutEvent;
use Symfony\Component\Security\Http\EventListener\CookieClearingLogoutListener;
class CookieClearingLogoutListenerTest extends TestCase
{ public function testLogout() { $response =
new Response();
$event =
new LogoutEvent(new Request(), null
);
$event->
setResponse($response);
$listener =
new CookieClearingLogoutListener(['foo' =>
['path' => '/foo', 'domain' => 'foo.foo', 'secure' => true, 'samesite' => Cookie::SAMESITE_STRICT
], 'foo2' =>
['path' => null, 'domain' => null
]]);
$cookies =
$response->headers->
getCookies();
$this->
assertCount(0,
$cookies);
$listener->
onLogout($event);
$cookies =
$response->headers->
getCookies(ResponseHeaderBag::COOKIES_ARRAY
);
$this->
assertCount(2,
$cookies);