Differential D14862 Diff 35939 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 107 Lines • ▼ Show 20 Lines | public function testEditProject() { | ||||
try { | try { | ||||
$this->attemptProjectEdit($proj, $user); | $this->attemptProjectEdit($proj, $user); | ||||
} catch (Exception $ex) { | } catch (Exception $ex) { | ||||
$caught = $ex; | $caught = $ex; | ||||
} | } | ||||
$this->assertTrue($caught instanceof Exception); | $this->assertTrue($caught instanceof Exception); | ||||
} | } | ||||
public function testAncestryQueries() { | |||||
$user = $this->createUser(); | |||||
$user->save(); | |||||
$ancestor = $this->createProject($user); | |||||
$parent = $this->createProject($user, $ancestor); | |||||
$child = $this->createProject($user, $parent); | |||||
$projects = id(new PhabricatorProjectQuery()) | |||||
->setViewer($user) | |||||
->withAncestorProjectPHIDs(array($ancestor->getPHID())) | |||||
->execute(); | |||||
$this->assertEqual(2, count($projects)); | |||||
$projects = id(new PhabricatorProjectQuery()) | |||||
->setViewer($user) | |||||
->withParentProjectPHIDs(array($ancestor->getPHID())) | |||||
->execute(); | |||||
$this->assertEqual(1, count($projects)); | |||||
$this->assertEqual( | |||||
$parent->getPHID(), | |||||
head($projects)->getPHID()); | |||||
$projects = id(new PhabricatorProjectQuery()) | |||||
->setViewer($user) | |||||
->withAncestorProjectPHIDs(array($ancestor->getPHID())) | |||||
->withDepthBetween(2, null) | |||||
->execute(); | |||||
$this->assertEqual(1, count($projects)); | |||||
$this->assertEqual( | |||||
$child->getPHID(), | |||||
head($projects)->getPHID()); | |||||
$parent2 = $this->createProject($user, $ancestor); | |||||
$child2 = $this->createProject($user, $parent2); | |||||
$grandchild2 = $this->createProject($user, $child2); | |||||
$projects = id(new PhabricatorProjectQuery()) | |||||
->setViewer($user) | |||||
->withAncestorProjectPHIDs(array($ancestor->getPHID())) | |||||
->execute(); | |||||
$this->assertEqual(5, count($projects)); | |||||
$projects = id(new PhabricatorProjectQuery()) | |||||
->setViewer($user) | |||||
->withParentProjectPHIDs(array($ancestor->getPHID())) | |||||
->execute(); | |||||
$this->assertEqual(2, count($projects)); | |||||
$projects = id(new PhabricatorProjectQuery()) | |||||
->setViewer($user) | |||||
->withAncestorProjectPHIDs(array($ancestor->getPHID())) | |||||
->withDepthBetween(2, null) | |||||
->execute(); | |||||
$this->assertEqual(3, count($projects)); | |||||
$projects = id(new PhabricatorProjectQuery()) | |||||
->setViewer($user) | |||||
->withAncestorProjectPHIDs(array($ancestor->getPHID())) | |||||
->withDepthBetween(3, null) | |||||
->execute(); | |||||
$this->assertEqual(1, count($projects)); | |||||
$projects = id(new PhabricatorProjectQuery()) | |||||
->setViewer($user) | |||||
->withPHIDs( | |||||
array( | |||||
$child->getPHID(), | |||||
$grandchild2->getPHID(), | |||||
)) | |||||
->execute(); | |||||
$this->assertEqual(2, count($projects)); | |||||
} | |||||
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 340 Lines • Show Last 20 Lines |