Skip to content

Commit

Permalink
Fix ResourceAccessCheckerTest (#3322)
Browse files Browse the repository at this point in the history
  • Loading branch information
alanpoulain committed Dec 21, 2019
1 parent c593d41 commit f78e3e3
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tests/Security/ResourceAccessCheckerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,15 @@ public function testIsGranted(bool $granted)
$tokenStorageProphecy = $this->prophesize(TokenStorageInterface::class);

$tokenProphecy = $this->prophesize(TokenInterface::class);
$token = $tokenProphecy->reveal();
$tokenProphecy->getUser()->shouldBeCalled();
$tokenProphecy->getRoles()->willReturn([])->shouldBeCalled();
$tokenProphecy->reveal();
if (method_exists($token, 'getRoleNames')) {
$tokenProphecy->getRoleNames()->willReturn([])->shouldBeCalled();
} else {
$tokenProphecy->getRoles()->willReturn([])->shouldBeCalled();
}

$tokenStorageProphecy->getToken()->willReturn($tokenProphecy);
$tokenStorageProphecy->getToken()->willReturn($token);

$checker = new ResourceAccessChecker($expressionLanguageProphecy->reveal(), $authenticationTrustResolverProphecy->reveal(), null, $tokenStorageProphecy->reveal());
$this->assertSame($granted, $checker->isGranted(Dummy::class, 'is_granted("ROLE_ADMIN")'));
Expand Down

0 comments on commit f78e3e3

Please sign in to comment.