From 0ca15f1f3b9cb01b322afbc130d0071a44b44b69 Mon Sep 17 00:00:00 2001 From: deedydas Date: Fri, 3 May 2013 08:13:58 -0700 Subject: [PATCH] Fixed Project Generation Summary: Ref T2903 Test Plan: Projects still generating with @epriestley's recommendations Reviewers: epriestley, AnhNhan Reviewed By: AnhNhan CC: aran, Korvin, AnhNhan Maniphest Tasks: T2903 Differential Revision: https://secure.phabricator.com/D5800 --- .../generator/PhabricatorTestDataGenerator.php | 9 +++++++++ ...habricatorManiphestTaskTestDataGenerator.php | 10 +--------- .../PhabricatorPasteTestDataGenerator.php | 10 +--------- .../PhabricatorProjectTestDataGenerator.php | 17 +++++------------ 4 files changed, 16 insertions(+), 30 deletions(-) diff --git a/src/applications/lipsum/generator/PhabricatorTestDataGenerator.php b/src/applications/lipsum/generator/PhabricatorTestDataGenerator.php index 814919e23c..6470f6c26f 100644 --- a/src/applications/lipsum/generator/PhabricatorTestDataGenerator.php +++ b/src/applications/lipsum/generator/PhabricatorTestDataGenerator.php @@ -16,4 +16,13 @@ abstract class PhabricatorTestDataGenerator { } } + + public function loadPhabrictorUserPHID() { + return $this->loadOneRandom("PhabricatorUser")->getPHID(); + } + + public function loadPhabrictorUser() { + return $this->loadOneRandom("PhabricatorUser"); + } + } diff --git a/src/applications/maniphest/lipsum/PhabricatorManiphestTaskTestDataGenerator.php b/src/applications/maniphest/lipsum/PhabricatorManiphestTaskTestDataGenerator.php index 6a04324a48..3245e19a76 100644 --- a/src/applications/maniphest/lipsum/PhabricatorManiphestTaskTestDataGenerator.php +++ b/src/applications/maniphest/lipsum/PhabricatorManiphestTaskTestDataGenerator.php @@ -4,7 +4,7 @@ final class PhabricatorManiphestTaskTestDataGenerator extends PhabricatorTestDataGenerator { public function generate() { - $authorPHID = $this->loadAuthorPHID(); + $authorPHID = $this->loadPhabrictorUserPHID(); $author = id(new PhabricatorUser()) ->loadOneWhere('phid = %s', $authorPHID); $task = id(new ManiphestTask()) @@ -77,14 +77,6 @@ final class PhabricatorManiphestTaskTestDataGenerator return $projects; } - private function loadPhabrictorUserPHID() { - return $this->loadOneRandom("PhabricatorUser")->getPHID(); - } - - public function loadAuthorPHID() { - return $this->loadPhabrictorUserPHID(); - } - public function loadOwnerPHID() { if (rand(0, 3) == 0) { return null; diff --git a/src/applications/paste/lipsum/PhabricatorPasteTestDataGenerator.php b/src/applications/paste/lipsum/PhabricatorPasteTestDataGenerator.php index fe31a45834..dd99bb4811 100644 --- a/src/applications/paste/lipsum/PhabricatorPasteTestDataGenerator.php +++ b/src/applications/paste/lipsum/PhabricatorPasteTestDataGenerator.php @@ -9,7 +9,7 @@ final class PhabricatorPasteTestDataGenerator "PHP" => "php"); public function generate() { - $authorphid = $this->loadAuthorPHID(); + $authorphid = $this->loadPhabrictorUserPHID(); $language = $this->generateLanguage(); $content = $this->generateContent($language); $title = $this->generateTitle($language); @@ -45,14 +45,6 @@ final class PhabricatorPasteTestDataGenerator return null; } - private function loadPhabrictorUserPHID() { - return id($this->loadOneRandom("PhabricatorUser"))->getPHID(); - } - - public function loadAuthorPHID() { - return $this->loadPhabrictorUserPHID(); - } - public function generateTitle($language = null) { $taskgen = new PhutilLipsumContextFreeGrammar(); // Remove Punctuation diff --git a/src/applications/project/lipsum/PhabricatorProjectTestDataGenerator.php b/src/applications/project/lipsum/PhabricatorProjectTestDataGenerator.php index af726170a8..216d584df0 100644 --- a/src/applications/project/lipsum/PhabricatorProjectTestDataGenerator.php +++ b/src/applications/project/lipsum/PhabricatorProjectTestDataGenerator.php @@ -7,17 +7,18 @@ final class PhabricatorProjectTestDataGenerator public function generate() { $title = $this->generateTitle(); - $author = $this->loadAuthorPHID(); + $author = $this->loadPhabrictorUser(); + $authorPHID = $author->getPHID(); $project = id(new PhabricatorProject()) ->setName($title) - ->setAuthorPHID($author); + ->setAuthorPHID($authorPHID); $this->addTransaction( PhabricatorProjectTransactionType::TYPE_NAME, $title); $this->addTransaction( PhabricatorProjectTransactionType::TYPE_MEMBERS, - $this->loadMembersWithAuthor($author)); + $this->loadMembersWithAuthor($authorPHID)); $this->addTransaction( PhabricatorProjectTransactionType::TYPE_STATUS, $this->generateProjectStatus()); @@ -32,8 +33,7 @@ final class PhabricatorProjectTestDataGenerator PhabricatorPolicies::POLICY_PUBLIC); $editor = id(new PhabricatorProjectEditor($project)) - ->setActor(id(new PhabricatorUser()) - ->loadOneWhere('phid = %s', $author)) + ->setActor($author) ->applyTransactions($this->xactions); $profile = id(new PhabricatorProjectProfile()) @@ -50,13 +50,6 @@ final class PhabricatorProjectTestDataGenerator ->setNewValue($value); } - private function loadPhabrictorUserPHID() { - return $this->loadOneRandom("PhabricatorUser")->getPHID(); - } - - public function loadAuthorPHID() { - return $this->loadPhabrictorUserPHID(); - } public function loadMembersWithAuthor($author) { $members = array($author);