isGranted() public method

Returns TRUE, if the given privilege type is granted for the given subject based on the current security context.
public isGranted ( string $privilegeType, mixed $subject, string &$reason = '' ) : boolean
$privilegeType string The type of privilege that should be evaluated
$subject mixed The subject to check privileges for
$reason string This variable will be filled by a message giving information about the reasons for the result of this method
return boolean
 /**
  * @test
  */
 public function isGrantedGrantsAccessIfAGrantPrivilegeAndNoDenyPrivilegeWasConfigured()
 {
     $role1ClassName = 'role1' . md5(uniqid(mt_rand(), true));
     $role2ClassName = 'role2' . md5(uniqid(mt_rand(), true));
     $mockRoleAdministrator = $this->createMock(Security\Policy\Role::class, [], [], $role1ClassName, false);
     $mockRoleAdministrator->expects($this->any())->method('getPrivilegesByType')->will($this->returnValue([$this->grantPrivilege]));
     $mockRoleCustomer = $this->createMock(Security\Policy\Role::class, [], [], $role2ClassName, false);
     $mockRoleCustomer->expects($this->any())->method('getPrivilegesByType')->will($this->returnValue([]));
     $this->mockSecurityContext->expects($this->once())->method('getRoles')->will($this->returnValue([$mockRoleAdministrator, $mockRoleCustomer]));
     $this->assertTrue($this->privilegeManager->isGranted(MethodPrivilegeInterface::class, new MethodPrivilegeSubject($this->mockJoinPoint)));
 }
 /**
  * Returns TRUE, if the given privilege type is granted for the given subject based
  * on the current security context or if set based on the override decision value.
  *
  * @param string $privilegeType
  * @param mixed $subject
  * @param string $reason This variable will be filled by a message giving information about the reasons for the result of this method
  * @return boolean
  */
 public function isGranted($privilegeType, $subject, &$reason = '')
 {
     if ($this->overrideDecision === false) {
         $reason = 'Voting has been overriden to "DENY" by the testing privilege manager!';
         return false;
     } elseif ($this->overrideDecision === true) {
         $reason = 'Voting has been overriden to "GRANT" by the testing privilege manager!';
         return true;
     }
     return parent::isGranted($privilegeType, $subject, $reason);
 }