Skip to content

Commit

Permalink
[Security] Removed an unnecessary call to sprintf() and added a test …
Browse files Browse the repository at this point in the history
…case.
  • Loading branch information
jakzal committed Jun 2, 2013
1 parent 6b25213 commit 314f29a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Expand Up @@ -49,7 +49,7 @@ public function handle(GetResponseEvent $event)
$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');
}
}
}
Expand Up @@ -59,4 +59,21 @@ public function testHandleWithContextHavingNoToken()
$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));
}
}

0 comments on commit 314f29a

Please sign in to comment.