Пример #1
0
 public function testIsObjectSharedWithUser()
 {
     $token = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface')->disableOriginalConstructor()->getMock();
     $object = $this->getMockBuilder('Symfony\\Component\\Security\\Acl\\Model\\DomainObjectInterface')->disableOriginalConstructor()->getMock();
     $acl = $this->getMockBuilder('Symfony\\Component\\Security\\Acl\\Model\\AclInterface')->disableOriginalConstructor()->getMock();
     $sid = $this->getMockBuilder('Symfony\\Component\\Security\\Acl\\Model\\SecurityIdentityInterface')->disableOriginalConstructor()->getMock();
     $ace = $this->getMockBuilder('Symfony\\Component\\Security\\Acl\\Domain\\Entry')->disableOriginalConstructor()->getMock();
     $aceSid = $this->getMockBuilder('Symfony\\Component\\Security\\Acl\\Model\\SecurityIdentityInterface')->disableOriginalConstructor()->getMock();
     $this->aclProvider->expects($this->once())->method('findAcl')->willReturn($acl);
     $this->sidRetrievalStrategy->expects($this->once())->method('getSecurityIdentities')->willReturn([$sid]);
     $acl->expects($this->once())->method('getObjectAces')->willReturn([$ace]);
     $sid->expects($this->once())->method('equals')->willReturn(true);
     $ace->expects($this->once())->method('getSecurityIdentity')->willReturn($aceSid);
     $this->assertTrue($this->shareProvider->isObjectSharedWithUser($object, $token));
 }
Пример #2
0
 /**
  * Determines if object is shared with logged user.
  *
  * @param $object
  *
  * @return bool
  */
 public function isObjectSharedWithUser($object)
 {
     return $this->shareProvider->isObjectSharedWithUser($object, $this->getToken());
 }