/** * @dataProvider provideObjectIdentifiers */ public function testSetPermissionsWithExistingAcl($objectId, $objectType, $objectIdentifier) { $symfonySecurityIdentity = $this->prophesize(SymfonySecurityIdentityInterface::class); $symfonySecurityIdentity->equals(Argument::any())->willReturn(true); $ace = $this->prophesize(Entry::class); $ace->getSecurityIdentity()->willReturn($symfonySecurityIdentity); $ace->getId()->willReturn(0); $this->aclProvider->findAcl(new ObjectIdentity($objectIdentifier, $objectType))->willReturn($this->acl->reveal())->shouldBeCalled(); $this->aclProvider->createAcl(Argument::cetera())->shouldNotBeCalled(); $this->aclProvider->updateAcl($this->acl->reveal())->shouldBeCalled(); $this->acl->getObjectAces()->willReturn([$ace->reveal()]); $this->acl->updateObjectAce(0, Argument::any())->shouldBeCalled(); $this->accessControlManager->setPermissions($objectType, $objectId, [$this->securityIdentity->getRole() => ['view']]); }
/** * Update ACL entries * * @param MutableAclInterface $acl * @param array $update */ protected function updateAclEntries(MutableAclInterface $acl, array $update) { foreach ($update as $index => $entry) { $acl->updateObjectAce($index, $entry['permission']); } }