diff --git a/src/Symfony/Component/Security/Http/Firewall/AnonymousAuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/AnonymousAuthenticationListener.php index af2213bc25..59f05ff625 100644 --- a/src/Symfony/Component/Security/Http/Firewall/AnonymousAuthenticationListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/AnonymousAuthenticationListener.php @@ -49,7 +49,7 @@ class AnonymousAuthenticationListener implements ListenerInterface $this->context->setToken(new AnonymousToken($this->key, 'anon.', array())); if (null !== $this->logger) { - $this->logger->info(sprintf('Populated SecurityContext with an anonymous Token')); + $this->logger->info('Populated SecurityContext with an anonymous Token'); } } } diff --git a/src/Symfony/Component/Security/Tests/Http/Firewall/AnonymousAuthenticationListenerTest.php b/src/Symfony/Component/Security/Tests/Http/Firewall/AnonymousAuthenticationListenerTest.php index 9e7ea90a0e..73ee8214de 100644 --- a/src/Symfony/Component/Security/Tests/Http/Firewall/AnonymousAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Tests/Http/Firewall/AnonymousAuthenticationListenerTest.php @@ -59,4 +59,21 @@ class AnonymousAuthenticationListenerTest extends \PHPUnit_Framework_TestCase $listener = new AnonymousAuthenticationListener($context, 'TheKey'); $listener->handle($this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false)); } + + public function testHandledEventIsLogged() + { + if (!interface_exists('Psr\Log\LoggerInterface')) { + $this->markTestSkipped('The "LoggerInterface" is not available'); + } + + $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)); + } }