public function testHandleWithContextHavingNoToken() { $context = $this->getMock('Symfony\\Component\\Security\\Core\\SecurityContextInterface'); $context->expects($this->any())->method('getToken')->will($this->returnValue(null)); $context->expects($this->once())->method('setToken')->with(self::logicalAnd($this->isInstanceOf('Symfony\\Component\\Security\\Core\\Authentication\\Token\\AnonymousToken'), $this->attributeEqualTo('key', 'TheKey'))); $listener = new AnonymousAuthenticationListener($context, 'TheKey'); $listener->handle($this->getMock('Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent', array(), array(), '', false)); }
public function testHandledEventIsLogged() { $context = $this->getMock('Symfony\\Component\\Security\\Core\\SecurityContextInterface'); $logger = $this->getMock('Psr\\Log\\LoggerInterface'); $logger->expects($this->once())->method('info')->with('Populated SecurityContext with an anonymous Token'); $listener = new AnonymousAuthenticationListener($context, 'TheKey', $logger); $listener->handle($this->getMock('Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent', array(), array(), '', false)); }
public function testHandledEventIsLogged() { $tokenStorage = $this->getMock('Symfony\\Component\\Security\\Core\\Authentication\\Token\\Storage\\TokenStorageInterface'); $logger = $this->getMock('Psr\\Log\\LoggerInterface'); $logger->expects($this->once())->method('info')->with('Populated the TokenStorage with an anonymous Token.'); $authenticationManager = $this->getMock('Symfony\\Component\\Security\\Core\\Authentication\\AuthenticationManagerInterface'); $listener = new AnonymousAuthenticationListener($tokenStorage, 'TheSecret', $logger, $authenticationManager); $listener->handle($this->getMock('Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent', array(), array(), '', false)); }