Example #1
0
 private function isOwner(OwnerInterface $owner, OwnableInterface $ownable)
 {
     if ($ownable->getOwner() instanceof UserInterface && $owner instanceof EquatableInterface) {
         return $owner->isEqualTo($ownable->getOwner());
     }
     return $ownable->getOwner() === $owner;
 }
Example #2
0
 function it_denies_access_to_not_equal_owners(TokenInterface $token, UserInterface $user, OwnableInterface $object, UserInterface $equatableUser)
 {
     $user->implement('Knp\\Rad\\Security\\OwnerInterface');
     $user->implement('Symfony\\Component\\Security\\Core\\User\\EquatableInterface');
     $token->getUser()->willReturn($user);
     $object->getOwner()->willReturn($equatableUser);
     $user->isEqualTo($equatableUser)->willReturn(false);
     $this->vote($token, $object, array('IS_OWNER'))->shouldReturn(VoterInterface::ACCESS_DENIED);
 }