Skip to content

Commit 0ca15f1

Browse files
deedyepriestley
authored andcommitted
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
1 parent 89747c0 commit 0ca15f1

File tree

4 files changed

+16
-30
lines changed

4 files changed

+16
-30
lines changed

src/applications/lipsum/generator/PhabricatorTestDataGenerator.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,13 @@ public function loadOneRandom($classname) {
1616
}
1717
}
1818

19+
20+
public function loadPhabrictorUserPHID() {
21+
return $this->loadOneRandom("PhabricatorUser")->getPHID();
22+
}
23+
24+
public function loadPhabrictorUser() {
25+
return $this->loadOneRandom("PhabricatorUser");
26+
}
27+
1928
}

src/applications/maniphest/lipsum/PhabricatorManiphestTaskTestDataGenerator.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ final class PhabricatorManiphestTaskTestDataGenerator
44
extends PhabricatorTestDataGenerator {
55

66
public function generate() {
7-
$authorPHID = $this->loadAuthorPHID();
7+
$authorPHID = $this->loadPhabrictorUserPHID();
88
$author = id(new PhabricatorUser())
99
->loadOneWhere('phid = %s', $authorPHID);
1010
$task = id(new ManiphestTask())
@@ -77,14 +77,6 @@ public function getProjectPHIDs() {
7777
return $projects;
7878
}
7979

80-
private function loadPhabrictorUserPHID() {
81-
return $this->loadOneRandom("PhabricatorUser")->getPHID();
82-
}
83-
84-
public function loadAuthorPHID() {
85-
return $this->loadPhabrictorUserPHID();
86-
}
87-
8880
public function loadOwnerPHID() {
8981
if (rand(0, 3) == 0) {
9082
return null;

src/applications/paste/lipsum/PhabricatorPasteTestDataGenerator.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ final class PhabricatorPasteTestDataGenerator
99
"PHP" => "php");
1010

1111
public function generate() {
12-
$authorphid = $this->loadAuthorPHID();
12+
$authorphid = $this->loadPhabrictorUserPHID();
1313
$language = $this->generateLanguage();
1414
$content = $this->generateContent($language);
1515
$title = $this->generateTitle($language);
@@ -45,14 +45,6 @@ private function loadPhabrictorPastePHID() {
4545
return null;
4646
}
4747

48-
private function loadPhabrictorUserPHID() {
49-
return id($this->loadOneRandom("PhabricatorUser"))->getPHID();
50-
}
51-
52-
public function loadAuthorPHID() {
53-
return $this->loadPhabrictorUserPHID();
54-
}
55-
5648
public function generateTitle($language = null) {
5749
$taskgen = new PhutilLipsumContextFreeGrammar();
5850
// Remove Punctuation

src/applications/project/lipsum/PhabricatorProjectTestDataGenerator.php

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,18 @@ final class PhabricatorProjectTestDataGenerator
77

88
public function generate() {
99
$title = $this->generateTitle();
10-
$author = $this->loadAuthorPHID();
10+
$author = $this->loadPhabrictorUser();
11+
$authorPHID = $author->getPHID();
1112
$project = id(new PhabricatorProject())
1213
->setName($title)
13-
->setAuthorPHID($author);
14+
->setAuthorPHID($authorPHID);
1415

1516
$this->addTransaction(
1617
PhabricatorProjectTransactionType::TYPE_NAME,
1718
$title);
1819
$this->addTransaction(
1920
PhabricatorProjectTransactionType::TYPE_MEMBERS,
20-
$this->loadMembersWithAuthor($author));
21+
$this->loadMembersWithAuthor($authorPHID));
2122
$this->addTransaction(
2223
PhabricatorProjectTransactionType::TYPE_STATUS,
2324
$this->generateProjectStatus());
@@ -32,8 +33,7 @@ public function generate() {
3233
PhabricatorPolicies::POLICY_PUBLIC);
3334

3435
$editor = id(new PhabricatorProjectEditor($project))
35-
->setActor(id(new PhabricatorUser())
36-
->loadOneWhere('phid = %s', $author))
36+
->setActor($author)
3737
->applyTransactions($this->xactions);
3838

3939
$profile = id(new PhabricatorProjectProfile())
@@ -50,13 +50,6 @@ private function addTransaction($type, $value) {
5050
->setNewValue($value);
5151
}
5252

53-
private function loadPhabrictorUserPHID() {
54-
return $this->loadOneRandom("PhabricatorUser")->getPHID();
55-
}
56-
57-
public function loadAuthorPHID() {
58-
return $this->loadPhabrictorUserPHID();
59-
}
6053

6154
public function loadMembersWithAuthor($author) {
6255
$members = array($author);

0 commit comments

Comments
 (0)