Esempio n. 1
0
 public function testIsObjectSharedWithUserSid()
 {
     $user = new User(1, 2, 'test_user');
     $object = $this->getMockBuilder('Symfony\\Component\\Security\\Acl\\Model\\DomainObjectInterface')->disableOriginalConstructor()->getMock();
     $acl = $this->getMockBuilder('Symfony\\Component\\Security\\Acl\\Model\\AclInterface')->disableOriginalConstructor()->getMock();
     $aceSid = new UserSecurityIdentity('test_user', 'Symfony\\Bridge\\Doctrine\\Tests\\Fixtures\\User');
     $ace = $this->getMockBuilder('Symfony\\Component\\Security\\Acl\\Domain\\Entry')->disableOriginalConstructor()->getMock();
     $this->aclProvider->expects($this->once())->method('findAcl')->willReturn($acl);
     $acl->expects($this->once())->method('getObjectAces')->willReturn([$ace]);
     $ace->expects($this->once())->method('getSecurityIdentity')->willReturn($aceSid);
     $this->assertTrue($this->shareProvider->isObjectSharedWithUserSid($object, $user));
 }
Esempio n. 2
0
 /**
  * Determines if object is shared with given user exactly. If no UserInterface entity is passed
  * then user will be taken from current context.
  *
  * @param $object
  * @param UserInterface|null $user
  *
  * @return bool
  */
 public function isObjectSharedWithUserSid($object, UserInterface $user = null)
 {
     if (!$user) {
         $user = $this->getLoggedUser();
     }
     return $this->shareProvider->isObjectSharedWithUserSid($object, $user);
 }