/**
  * @dataProvider aceTypesProvider
  */
 public function testDeletePermission($type, $field)
 {
     $sid = $this->createMock('Symfony\\Component\\Security\\Acl\\Model\\SecurityIdentityInterface');
     $granting = true;
     $mask = 123;
     $strategy = 'any';
     $aceSid1 = $this->createMock('Symfony\\Component\\Security\\Acl\\Model\\SecurityIdentityInterface');
     $aceGranting1 = true;
     $aceMask1 = 123;
     $aceStrategy1 = 'equal';
     $aceSid2 = $this->createMock('Symfony\\Component\\Security\\Acl\\Model\\SecurityIdentityInterface');
     $aceSid3 = $this->createMock('Symfony\\Component\\Security\\Acl\\Model\\SecurityIdentityInterface');
     $aceGranting3 = $granting;
     $aceMask3 = $mask;
     $aceStrategy3 = $strategy;
     $ace1 = $this->getAce($aceSid1, $aceGranting1, $aceMask1, $aceStrategy1);
     $ace2 = $this->getAce($aceSid2);
     $ace3 = $this->getAce($aceSid3, $aceGranting3, $aceMask3, $aceStrategy3);
     $sid->expects($this->at(0))->method('equals')->with($this->identicalTo($aceSid1))->will($this->returnValue(true));
     $sid->expects($this->at(1))->method('equals')->with($this->identicalTo($aceSid2))->will($this->returnValue(false));
     $sid->expects($this->at(2))->method('equals')->with($this->identicalTo($aceSid3))->will($this->returnValue(true));
     if ($field === null) {
         $this->acl->expects($this->once())->method('get' . $type . 'Aces')->will($this->returnValue([$ace1, $ace2, $ace3]));
     } else {
         $this->acl->expects($this->once())->method('get' . $type . 'FieldAces')->with($this->equalTo($field))->will($this->returnValue([$ace1, $ace2, $ace3]));
     }
     if ($field === null) {
         $this->acl->expects($this->once())->method('delete' . $type . 'Ace')->with($this->equalTo(2));
     } else {
         $this->acl->expects($this->once())->method('delete' . $type . 'FieldAce')->with($this->equalTo(2), $this->equalTo($field));
     }
     $this->assertTrue($this->manipulator->deletePermission($this->acl, $type, $field, $sid, $granting, $mask, $strategy));
 }
예제 #2
0
 /**
  * Deletes ACE with the given attributes
  *
  * @param SID $sid
  * @param OID $oid
  * @param string $type The ACE type. Can be one of self::*_ACE constants
  * @param string|null $field The name of a field.
  *                           Set to null for class-based or object-based ACE
  *                           Set to not null class-field-based or object-field-based ACE
  * @param int $mask
  * @param bool $granting
  * @param string|null $strategy If null ACE with any strategy should be deleted
  */
 protected function doDeletePermission(SID $sid, OID $oid, $type, $field, $mask, $granting, $strategy = null)
 {
     $acl = $this->getAcl($oid);
     $key = $this->getKey($oid);
     if ($this->items[$key]->getState() !== BatchItem::STATE_DELETE) {
         if ($acl === null && $this->items[$key]->getState() === BatchItem::STATE_CREATE) {
             $this->items[$key]->removeAce($type, $field, $sid, $granting, $mask, $strategy);
         } else {
             $hasChanges = $this->aceProvider->deletePermission($acl, $type, $field, $sid, $granting, $mask, $strategy);
             if ($hasChanges) {
                 $this->items[$key]->setState(BatchItem::STATE_UPDATE);
             }
         }
     }
 }