Changeset View
Changeset View
Standalone View
Standalone View
src/applications/policy/__tests__/PhabricatorPolicyDataTestCase.php
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | public function testCustomPolicyRuleUser() { | ||||
$user_b = $this->generateNewTestUser(); | $user_b = $this->generateNewTestUser(); | ||||
$author = $this->generateNewTestUser(); | $author = $this->generateNewTestUser(); | ||||
$policy = id(new PhabricatorPolicy()) | $policy = id(new PhabricatorPolicy()) | ||||
->setRules( | ->setRules( | ||||
array( | array( | ||||
array( | array( | ||||
'action' => PhabricatorPolicy::ACTION_ALLOW, | 'action' => PhabricatorPolicy::ACTION_ALLOW, | ||||
'rule' => 'PhabricatorPolicyRuleUsers', | 'rule' => 'PhabricatorUsersPolicyRule', | ||||
'value' => array($user_a->getPHID()), | 'value' => array($user_a->getPHID()), | ||||
), | ), | ||||
)) | )) | ||||
->save(); | ->save(); | ||||
$task = ManiphestTask::initializeNewTask($author); | $task = ManiphestTask::initializeNewTask($author); | ||||
$task->setViewPolicy($policy->getPHID()); | $task->setViewPolicy($policy->getPHID()); | ||||
$task->save(); | $task->save(); | ||||
Show All 19 Lines | public function testCustomPolicyRuleAdministrators() { | ||||
$user_b = $this->generateNewTestUser(); | $user_b = $this->generateNewTestUser(); | ||||
$author = $this->generateNewTestUser(); | $author = $this->generateNewTestUser(); | ||||
$policy = id(new PhabricatorPolicy()) | $policy = id(new PhabricatorPolicy()) | ||||
->setRules( | ->setRules( | ||||
array( | array( | ||||
array( | array( | ||||
'action' => PhabricatorPolicy::ACTION_ALLOW, | 'action' => PhabricatorPolicy::ACTION_ALLOW, | ||||
'rule' => 'PhabricatorPolicyRuleAdministrators', | 'rule' => 'PhabricatorAdministratorsPolicyRule', | ||||
'value' => null, | 'value' => null, | ||||
), | ), | ||||
)) | )) | ||||
->save(); | ->save(); | ||||
$task = ManiphestTask::initializeNewTask($author); | $task = ManiphestTask::initializeNewTask($author); | ||||
$task->setViewPolicy($policy->getPHID()); | $task->setViewPolicy($policy->getPHID()); | ||||
$task->save(); | $task->save(); | ||||
Show All 17 Lines | public function testCustomPolicyRuleLunarPhase() { | ||||
$user_a = $this->generateNewTestUser(); | $user_a = $this->generateNewTestUser(); | ||||
$author = $this->generateNewTestUser(); | $author = $this->generateNewTestUser(); | ||||
$policy = id(new PhabricatorPolicy()) | $policy = id(new PhabricatorPolicy()) | ||||
->setRules( | ->setRules( | ||||
array( | array( | ||||
array( | array( | ||||
'action' => PhabricatorPolicy::ACTION_ALLOW, | 'action' => PhabricatorPolicy::ACTION_ALLOW, | ||||
'rule' => 'PhabricatorPolicyRuleLunarPhase', | 'rule' => 'PhabricatorLunarPhasePolicyRule', | ||||
'value' => 'new', | 'value' => 'new', | ||||
), | ), | ||||
)) | )) | ||||
->save(); | ->save(); | ||||
$task = ManiphestTask::initializeNewTask($author); | $task = ManiphestTask::initializeNewTask($author); | ||||
$task->setViewPolicy($policy->getPHID()); | $task->setViewPolicy($policy->getPHID()); | ||||
$task->save(); | $task->save(); | ||||
Show All 24 Lines |