public function testHandleSuccessWithRememberMe()
 {
     $authenticator = $this->getMock('Symfony\\Component\\Security\\Guard\\GuardAuthenticatorInterface');
     $authenticateToken = $this->getMock('Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface');
     $providerKey = 'my_firewall_with_rememberme';
     $authenticator->expects($this->once())->method('getCredentials')->with($this->equalTo($this->request))->will($this->returnValue(array('username' => 'anything_not_empty')));
     $this->authenticationManager->expects($this->once())->method('authenticate')->will($this->returnValue($authenticateToken));
     $successResponse = new Response('Success!');
     $this->guardAuthenticatorHandler->expects($this->once())->method('handleAuthenticationSuccess')->will($this->returnValue($successResponse));
     $listener = new GuardAuthenticationListener($this->guardAuthenticatorHandler, $this->authenticationManager, $providerKey, array($authenticator), $this->logger);
     $listener->setRememberMeServices($this->rememberMeServices);
     $authenticator->expects($this->once())->method('supportsRememberMe')->will($this->returnValue(true));
     // should be called - we do have a success Response
     $this->rememberMeServices->expects($this->once())->method('loginSuccess');
     $listener->handle($this->event);
 }
 /**
  * @group legacy
  */
 public function testLegacyInterfaceKeepsWorking()
 {
     $authenticator = $this->getMock('Symfony\\Component\\Security\\Guard\\GuardAuthenticatorInterface');
     $authenticateToken = $this->getMock('Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface');
     $providerKey = 'my_firewall';
     $credentials = array('username' => 'weaverryan', 'password' => 'all_your_base');
     $authenticator->expects($this->once())->method('getCredentials')->with($this->equalTo($this->request))->will($this->returnValue($credentials));
     // a clone of the token that should be created internally
     $uniqueGuardKey = 'my_firewall_0';
     $nonAuthedToken = new PreAuthenticationGuardToken($credentials, $uniqueGuardKey);
     $this->authenticationManager->expects($this->once())->method('authenticate')->with($this->equalTo($nonAuthedToken))->will($this->returnValue($authenticateToken));
     $this->guardAuthenticatorHandler->expects($this->once())->method('authenticateWithToken')->with($authenticateToken, $this->request);
     $this->guardAuthenticatorHandler->expects($this->once())->method('handleAuthenticationSuccess')->with($authenticateToken, $this->request, $authenticator, $providerKey);
     $listener = new GuardAuthenticationListener($this->guardAuthenticatorHandler, $this->authenticationManager, $providerKey, array($authenticator), $this->logger);
     $listener->setRememberMeServices($this->rememberMeServices);
     // should never be called - our handleAuthenticationSuccess() does not return a Response
     $this->rememberMeServices->expects($this->never())->method('loginSuccess');
     $listener->handle($this->event);
 }