Differential D17152 Diff 41250 src/applications/project/__tests__/PhabricatorProjectCoreTestCase.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/project/__tests__/PhabricatorProjectCoreTestCase.php
Show First 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | public function testApplicationPolicy() { | ||||
$proj = $this->createProject($user); | $proj = $this->createProject($user); | ||||
$this->assertTrue( | $this->assertTrue( | ||||
PhabricatorPolicyFilter::hasCapability( | PhabricatorPolicyFilter::hasCapability( | ||||
$user, | $user, | ||||
$proj, | $proj, | ||||
PhabricatorPolicyCapability::CAN_VIEW)); | PhabricatorPolicyCapability::CAN_VIEW)); | ||||
// This object is visible so its handle should load normally. | |||||
$handle = id(new PhabricatorHandleQuery()) | |||||
->setViewer($user) | |||||
->withPHIDs(array($proj->getPHID())) | |||||
->executeOne(); | |||||
$this->assertEqual($proj->getPHID(), $handle->getPHID()); | |||||
// Change the "Can Use Application" policy for Projecs to "No One". This | // Change the "Can Use Application" policy for Projecs to "No One". This | ||||
// should cause filtering checks to fail even when they are executed | // should cause filtering checks to fail even when they are executed | ||||
// directly rather than via a Query. | // directly rather than via a Query. | ||||
$env = PhabricatorEnv::beginScopedEnv(); | $env = PhabricatorEnv::beginScopedEnv(); | ||||
$env->overrideEnvConfig( | $env->overrideEnvConfig( | ||||
'phabricator.application-settings', | 'phabricator.application-settings', | ||||
array( | array( | ||||
'PHID-APPS-PhabricatorProjectApplication' => array( | 'PHID-APPS-PhabricatorProjectApplication' => array( | ||||
Show All 9 Lines | public function testApplicationPolicy() { | ||||
PhabricatorCaches::destroyRequestCache(); | PhabricatorCaches::destroyRequestCache(); | ||||
$this->assertFalse( | $this->assertFalse( | ||||
PhabricatorPolicyFilter::hasCapability( | PhabricatorPolicyFilter::hasCapability( | ||||
$user, | $user, | ||||
$proj, | $proj, | ||||
PhabricatorPolicyCapability::CAN_VIEW)); | PhabricatorPolicyCapability::CAN_VIEW)); | ||||
// We should still be able to load a handle for the project, even if we | |||||
// can not see the application. | |||||
$handle = id(new PhabricatorHandleQuery()) | |||||
->setViewer($user) | |||||
->withPHIDs(array($proj->getPHID())) | |||||
->executeOne(); | |||||
// The handle should load... | |||||
$this->assertEqual($proj->getPHID(), $handle->getPHID()); | |||||
// ...but be policy filtered. | |||||
$this->assertTrue($handle->getPolicyFiltered()); | |||||
unset($env); | unset($env); | ||||
} | } | ||||
public function testIsViewerMemberOrWatcher() { | public function testIsViewerMemberOrWatcher() { | ||||
$user1 = $this->createUser() | $user1 = $this->createUser() | ||||
->save(); | ->save(); | ||||
$user2 = $this->createUser() | $user2 = $this->createUser() | ||||
▲ Show 20 Lines • Show All 1,482 Lines • Show Last 20 Lines |