public function testLogout()
 {
     $this->cookieService->expects($this->once())->method('read')->with($this->request, $this->response)->will($this->returnValue(new SerieToken(1, 'abc', 'def')));
     $this->rememberMeService->expects($this->once())->method('removeSerie')->with(1, 'abc');
     $this->cookieService->expects($this->once())->method('writeNull')->with($this->response);
     $this->listener->logout(new AdapterChainEvent());
 }
 public function onBootstrap(EventInterface $e)
 {
     /** @var EventManager $em */
     $em = $e->getApplication()->getEventManager();
     $request = $e->getApplication()->getRequest();
     $response = $e->getApplication()->getResponse();
     // Write token to cookie after valid authentication
     $placeCookie = new WriteTokenToCookie();
     $placeCookie->setRequest($request);
     $placeCookie->setResponse($response);
     $placeCookie->setServiceLocator($e->getApplication()->getServiceManager());
     $em->getSharedManager()->attachAggregate($placeCookie);
     // Try to login from Cookie if applicable
     $service = new CookieAuthenticationService();
     $service->setServiceLocator($e->getApplication()->getServiceManager());
     $service->loginFrom($request, $response);
 }