use Symfony\Component\Security\Http\Event\LogoutEvent;
use Symfony\Component\Security\Http\EventListener\SessionLogoutListener;
class SessionLogoutListenerTest extends TestCase
{ public function testOnLogoutIfHasNoSession() { $request =
$this->
createMock(Request::
class);
$request->
method('hasSession'
)->
willReturn(false
);
$request->
expects($this->
never())->
method('getSession'
);
$sessionLogoutListener =
new SessionLogoutListener();
$sessionLogoutListener->
onLogout(new LogoutEvent($request, null
));
} public function testOnLogoutIfHasSession() { $session =
$this->
createMock(Session::
class);
$session->
expects($this->
once())->
method('invalidate'
);
$request =
$this->
createMock(Request::
class);
$request->
method('getSession'
)->
willReturn($session);
$request->
method('hasSession'
)->
willReturn(true
);