Changeset View
Changeset View
Standalone View
Standalone View
src/applications/policy/__tests__/PhabricatorPolicyTestObject.php
| <?php | <?php | ||||
| /** | /** | ||||
| * Configurable test object for implementing Policy unit tests. | * Configurable test object for implementing Policy unit tests. | ||||
| */ | */ | ||||
| final class PhabricatorPolicyTestObject | final class PhabricatorPolicyTestObject | ||||
| implements PhabricatorPolicyInterface { | implements | ||||
| PhabricatorPolicyInterface, | |||||
| PhabricatorExtendedPolicyInterface { | |||||
| private $phid; | |||||
| private $capabilities = array(); | private $capabilities = array(); | ||||
| private $policies = array(); | private $policies = array(); | ||||
| private $automaticCapabilities = array(); | private $automaticCapabilities = array(); | ||||
| private $extendedPolicies = array(); | |||||
| public function setPHID($phid) { | |||||
| $this->phid = $phid; | |||||
| return $this; | |||||
| } | |||||
| public function getPHID() { | public function getPHID() { | ||||
| return null; | return $this->phid; | ||||
| } | } | ||||
| public function getCapabilities() { | public function getCapabilities() { | ||||
| return $this->capabilities; | return $this->capabilities; | ||||
| } | } | ||||
| public function getPolicy($capability) { | public function getPolicy($capability) { | ||||
| return idx($this->policies, $capability); | return idx($this->policies, $capability); | ||||
| Show All 18 Lines | public function setAutomaticCapabilities(array $auto_map) { | ||||
| $this->automaticCapabilities = $auto_map; | $this->automaticCapabilities = $auto_map; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function describeAutomaticCapability($capability) { | public function describeAutomaticCapability($capability) { | ||||
| return null; | return null; | ||||
| } | } | ||||
| public function setExtendedPolicies(array $extended_policies) { | |||||
| $this->extendedPolicies = $extended_policies; | |||||
| return $this; | |||||
| } | |||||
| public function getExtendedPolicy($capability, PhabricatorUser $viewer) { | |||||
| return idx($this->extendedPolicies, $capability, array()); | |||||
| } | |||||
| } | } | ||||