Differential D14869 Diff 35956 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 281 Lines • ▼ Show 20 Lines | public function testSameSlugAsName() { | ||||
$slugs = $project->getSlugs(); | $slugs = $project->getSlugs(); | ||||
$slugs = mpull($slugs, 'getSlug'); | $slugs = mpull($slugs, 'getSlug'); | ||||
$this->assertTrue(in_array($name, $slugs)); | $this->assertTrue(in_array($name, $slugs)); | ||||
// In this second case, set the name first and then the slugs separately. | // In this second case, set the name first and then the slugs separately. | ||||
$name2 = 'slugproject2'; | $name2 = 'slugproject2'; | ||||
$xactions = array(); | $xactions = array(); | ||||
$xactions[] = id(new PhabricatorProjectTransaction()) | $xactions[] = id(new PhabricatorProjectTransaction()) | ||||
->setTransactionType(PhabricatorProjectTransaction::TYPE_NAME) | ->setTransactionType(PhabricatorProjectTransaction::TYPE_NAME) | ||||
->setNewValue($name2); | ->setNewValue($name2); | ||||
$xactions[] = id(new PhabricatorProjectTransaction()) | $xactions[] = id(new PhabricatorProjectTransaction()) | ||||
->setTransactionType(PhabricatorProjectTransaction::TYPE_SLUGS) | ->setTransactionType(PhabricatorProjectTransaction::TYPE_SLUGS) | ||||
▲ Show 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | try { | ||||
$this->applyTransactions($project2, $user, $xactions); | $this->applyTransactions($project2, $user, $xactions); | ||||
} catch (PhabricatorApplicationTransactionValidationException $ex) { | } catch (PhabricatorApplicationTransactionValidationException $ex) { | ||||
$caught = $ex; | $caught = $ex; | ||||
} | } | ||||
$this->assertTrue((bool)$caught); | $this->assertTrue((bool)$caught); | ||||
} | } | ||||
public function testProjectMembersVisibility() { | |||||
// This is primarily testing that you can create a project and set the | |||||
// visibility or edit policy to "Project Members" immediately. | |||||
$user1 = $this->createUser(); | |||||
$user1->save(); | |||||
$user2 = $this->createUser(); | |||||
$user2->save(); | |||||
$project = PhabricatorProject::initializeNewProject($user1); | |||||
$name = pht('Test Project %d', mt_rand()); | |||||
$xactions = array(); | |||||
$xactions[] = id(new PhabricatorProjectTransaction()) | |||||
->setTransactionType(PhabricatorProjectTransaction::TYPE_NAME) | |||||
->setNewValue($name); | |||||
$xactions[] = id(new PhabricatorProjectTransaction()) | |||||
->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY) | |||||
->setNewValue( | |||||
id(new PhabricatorProjectMembersPolicyRule()) | |||||
->getObjectPolicyFullKey()); | |||||
$edge_type = PhabricatorProjectProjectHasMemberEdgeType::EDGECONST; | |||||
$xactions[] = id(new PhabricatorProjectTransaction()) | |||||
->setTransactionType(PhabricatorTransactions::TYPE_EDGE) | |||||
->setMetadataValue('edge:type', $edge_type) | |||||
->setNewValue( | |||||
array( | |||||
'=' => array($user1->getPHID() => $user1->getPHID()), | |||||
)); | |||||
$this->applyTransactions($project, $user1, $xactions); | |||||
$this->assertTrue((bool)$this->refreshProject($project, $user1)); | |||||
$this->assertFalse((bool)$this->refreshProject($project, $user2)); | |||||
$this->leaveProject($project, $user1); | |||||
$this->assertFalse((bool)$this->refreshProject($project, $user1)); | |||||
} | |||||
public function testParentProject() { | public function testParentProject() { | ||||
$user = $this->createUser(); | $user = $this->createUser(); | ||||
$user->save(); | $user->save(); | ||||
$parent = $this->createProject($user); | $parent = $this->createProject($user); | ||||
$child = $this->createProject($user, $parent); | $child = $this->createProject($user, $parent); | ||||
$this->assertTrue(true); | $this->assertTrue(true); | ||||
▲ Show 20 Lines • Show All 348 Lines • Show Last 20 Lines |