class AuthorizationCheckerTest extends TestCase
{ private MockObject&AccessDecisionManagerInterface
$accessDecisionManager;
private AuthorizationChecker
$authorizationChecker;
private TokenStorage
$tokenStorage;
protected function setUp(): void
{ $this->accessDecisionManager =
$this->
createMock(AccessDecisionManagerInterface::
class);
$this->tokenStorage =
new TokenStorage();
$this->authorizationChecker =
new AuthorizationChecker($this->tokenStorage,
$this->accessDecisionManager
);
} public function testVoteWithoutAuthenticationToken() { $authorizationChecker =
new AuthorizationChecker($this->tokenStorage,
$this->accessDecisionManager
);
$this->accessDecisionManager->
expects($this->
once())->
method('decide'
)->
with($this->
isInstanceOf(NullToken::
class))->
willReturn(false
);
$authorizationChecker->
isGranted('ROLE_FOO'
);
}