Differential D15054 Diff 36358 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 testAncestorMembers() { | |||||
| $user1 = $this->createUser(); | |||||
| $user1->save(); | |||||
| $user2 = $this->createUser(); | |||||
| $user2->save(); | |||||
| $parent = $this->createProject($user1); | |||||
| $child = $this->createProject($user1, $parent); | |||||
| $this->joinProject($child, $user1); | |||||
| $this->joinProject($child, $user2); | |||||
| $project = id(new PhabricatorProjectQuery()) | |||||
| ->setViewer($user1) | |||||
| ->withPHIDs(array($child->getPHID())) | |||||
| ->needAncestorMembers(true) | |||||
| ->executeOne(); | |||||
| $members = array_fuse($project->getParentProject()->getMemberPHIDs()); | |||||
| ksort($members); | |||||
| $expect = array_fuse( | |||||
| array( | |||||
| $user1->getPHID(), | |||||
| $user2->getPHID(), | |||||
| )); | |||||
| ksort($expect); | |||||
| $this->assertEqual($expect, $members); | |||||
| } | |||||
| public function testAncestryQueries() { | public function testAncestryQueries() { | ||||
| $user = $this->createUser(); | $user = $this->createUser(); | ||||
| $user->save(); | $user->save(); | ||||
| $ancestor = $this->createProject($user); | $ancestor = $this->createProject($user); | ||||
| $parent = $this->createProject($user, $ancestor); | $parent = $this->createProject($user, $ancestor); | ||||
| $child = $this->createProject($user, $parent); | $child = $this->createProject($user, $parent); | ||||
| ▲ Show 20 Lines • Show All 448 Lines • ▼ Show 20 Lines | public function testSlugMaps() { | ||||
| $actual = ipull($map, 'slug'); | $actual = ipull($map, 'slug'); | ||||
| ksort($expect); | ksort($expect); | ||||
| ksort($actual); | ksort($actual); | ||||
| $this->assertEqual($expect, $actual); | $this->assertEqual($expect, $actual); | ||||
| } | } | ||||
| private function attemptProjectEdit( | |||||
| PhabricatorProject $proj, | |||||
| PhabricatorUser $user, | |||||
| $skip_refresh = false) { | |||||
| $proj = $this->refreshProject($proj, $user, true); | |||||
| $new_name = $proj->getName().' '.mt_rand(); | |||||
| $xaction = new PhabricatorProjectTransaction(); | |||||
| $xaction->setTransactionType(PhabricatorProjectTransaction::TYPE_NAME); | |||||
| $xaction->setNewValue($new_name); | |||||
| $this->applyTransactions($proj, $user, array($xaction)); | |||||
| return true; | |||||
| } | |||||
| public function testJoinLeaveProject() { | public function testJoinLeaveProject() { | ||||
| $user = $this->createUser(); | $user = $this->createUser(); | ||||
| $user->save(); | $user->save(); | ||||
| $proj = $this->createProjectWithNewAuthor(); | $proj = $this->createProjectWithNewAuthor(); | ||||
| $proj = $this->refreshProject($proj, $user, true); | $proj = $this->refreshProject($proj, $user, true); | ||||
| $this->assertTrue( | $this->assertTrue( | ||||
| ▲ Show 20 Lines • Show All 183 Lines • ▼ Show 20 Lines | $this->assertQueryByProjects( | ||||
| array( | array( | ||||
| $task_diplomacy_scan, | $task_diplomacy_scan, | ||||
| $task_warp_scan, | $task_warp_scan, | ||||
| ), | ), | ||||
| array($engineering, $engineering_scan), | array($engineering, $engineering_scan), | ||||
| pht('Engineering + Scan')); | pht('Engineering + Scan')); | ||||
| } | } | ||||
| private function attemptProjectEdit( | |||||
| PhabricatorProject $proj, | |||||
| PhabricatorUser $user, | |||||
| $skip_refresh = false) { | |||||
| $proj = $this->refreshProject($proj, $user, true); | |||||
| $new_name = $proj->getName().' '.mt_rand(); | |||||
| $xaction = new PhabricatorProjectTransaction(); | |||||
| $xaction->setTransactionType(PhabricatorProjectTransaction::TYPE_NAME); | |||||
| $xaction->setNewValue($new_name); | |||||
| $this->applyTransactions($proj, $user, array($xaction)); | |||||
| return true; | |||||
| } | |||||
| private function newTask( | private function newTask( | ||||
| PhabricatorUser $viewer, | PhabricatorUser $viewer, | ||||
| array $projects, | array $projects, | ||||
| $name = null) { | $name = null) { | ||||
| $task = ManiphestTask::initializeNewTask($viewer); | $task = ManiphestTask::initializeNewTask($viewer); | ||||
| if (!strlen($name)) { | if (!strlen($name)) { | ||||
| ▲ Show 20 Lines • Show All 229 Lines • Show Last 20 Lines | |||||