private function setExpectationsForDeletePermission($sid, array $expectations) { $thisLink = $this; $this->expectationsForDeletePermission = $expectations; $this->triggeredExpectationsForDeletePermission = array(); $triggeredExpectationsForDeletePermission =& $this->triggeredExpectationsForDeletePermission; $this->manager->expects($this->any())->method('deletePermission')->with($this->identicalTo($sid))->will($this->returnCallback(function ($sid, $oid, $mask) use(&$thisLink, &$expectations, &$triggeredExpectationsForDeletePermission) { /** @var ObjectIdentity $oid */ $expectedMask = null; foreach ($expectations as $expectedOid => $expectedMasks) { if ($expectedOid === $oid->getIdentifier() . ':' . $oid->getType()) { $expectedMask = $thisLink->getMask($expectedMasks); $triggeredExpectationsForDeletePermission[$expectedOid] = isset($triggeredExpectationsForDeletePermission[$expectedOid]) ? $triggeredExpectationsForDeletePermission[$expectedOid] + 1 : 0; break; } } if ($expectedMask !== null) { if ($expectedMask !== $mask) { throw new \RuntimeException(sprintf('Call "deletePermission" with invalid mask for %s. Expected: %s. Actual: %s.', $oid, EntityMaskBuilder::getPatternFor($expectedMask), EntityMaskBuilder::getPatternFor($mask))); } } else { throw new \RuntimeException(sprintf('Unexpected call of "deletePermission" for %s.', $oid)); } })); }
/** * @dataProvider groupProvider */ public function testGroup($groupMask, $expectedMask) { $this->assertEquals($expectedMask, $groupMask, 'Actual: ' . EntityMaskBuilder::getPatternFor($groupMask)); }