Skip to content

Commit 9798307

Browse files
alamiraultfabpot
authored andcommitted
[Mime][Security] Fix missing sprintf and add tests
1 parent 83c8ef0 commit 9798307

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

Firewall/AccessListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class AccessListener extends AbstractListener
3737
public function __construct(TokenStorageInterface $tokenStorage, AccessDecisionManagerInterface $accessDecisionManager, AccessMapInterface $map, bool $exceptionOnNoToken = false)
3838
{
3939
if (false !== $exceptionOnNoToken) {
40-
throw new \LogicException('Argument $exceptionOnNoToken of "%s()" must be set to "false".', __METHOD__);
40+
throw new \LogicException(sprintf('Argument $exceptionOnNoToken of "%s()" must be set to "false".', __METHOD__));
4141
}
4242

4343
$this->tokenStorage = $tokenStorage;

Tests/Firewall/AccessListenerTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,4 +266,18 @@ public function testLazyPublicPagesShouldNotAccessTokenStorage()
266266
$listener = new AccessListener($tokenStorage, $this->createMock(AccessDecisionManagerInterface::class), $accessMap, false);
267267
$listener(new LazyResponseEvent(new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST)));
268268
}
269+
270+
public function testConstructWithTrueExceptionOnNoToken()
271+
{
272+
$tokenStorage = $this->createMock(TokenStorageInterface::class);
273+
$tokenStorage->expects($this->never())->method(self::anything());
274+
275+
$accessMap = $this->createMock(AccessMapInterface::class);
276+
277+
$this->expectExceptionObject(
278+
new \LogicException('Argument $exceptionOnNoToken of "Symfony\Component\Security\Http\Firewall\AccessListener::__construct()" must be set to "false".')
279+
);
280+
281+
new AccessListener($tokenStorage, $this->createMock(AccessDecisionManagerInterface::class), $accessMap, true);
282+
}
269283
}

0 commit comments

Comments
 (0)