public function testReturnNullToSkipAuth() { $authenticatorA = $this->getMock('Symfony\\Component\\Security\\Guard\\GuardAuthenticatorInterface'); $authenticatorB = $this->getMock('Symfony\\Component\\Security\\Guard\\GuardAuthenticatorInterface'); $providerKey = 'my_firewall3'; $authenticatorA->expects($this->once())->method('getCredentials')->will($this->returnValue(null)); $authenticatorB->expects($this->once())->method('getCredentials')->will($this->returnValue(null)); // this is not called $this->authenticationManager->expects($this->never())->method('authenticate'); $this->guardAuthenticatorHandler->expects($this->never())->method('handleAuthenticationSuccess'); $listener = new GuardAuthenticationListener($this->guardAuthenticatorHandler, $this->authenticationManager, $providerKey, array($authenticatorA, $authenticatorB), $this->logger); $listener->handle($this->event); }
/** * @expectedException \UnexpectedValueException */ public function testSupportsReturnTrueRaiseMissingCredentialsException() { $authenticator = $this->getMock('Symfony\\Component\\Security\\Guard\\Authenticator\\GuardAuthenticatorInterface'); $providerKey = 'my_firewall4'; $authenticator->expects($this->once())->method('supports')->will($this->returnValue(true)); // this will raise exception $authenticator->expects($this->once())->method('getCredentials')->will($this->returnValue(null)); $listener = new GuardAuthenticationListener($this->guardAuthenticatorHandler, $this->authenticationManager, $providerKey, array($authenticator), $this->logger); $listener->handle($this->event); }