mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-20 20:40:56 +01:00
Fix bin/lipsum
Summary: - Set a default edit policy to match view policy for projects - It seems like initializeNew* is a better init function than new Phabricator*, so ported two classes to use it and spot-checked the others (this also fixed a fatal.) - Other minor bugs Test Plan: Ran lipsum for a while without any fatals Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: epriestley, jhurwitz, Korvin Differential Revision: https://secure.phabricator.com/D13559
This commit is contained in:
parent
6d404c8219
commit
6a3c1ba05c
3 changed files with 13 additions and 9 deletions
|
@ -10,7 +10,8 @@ final class PhabricatorPasteTestDataGenerator
|
||||||
);
|
);
|
||||||
|
|
||||||
public function generate() {
|
public function generate() {
|
||||||
$authorphid = $this->loadPhabrictorUserPHID();
|
$author = $this->loadPhabrictorUser();
|
||||||
|
$authorphid = $author->getPHID();
|
||||||
$language = $this->generateLanguage();
|
$language = $this->generateLanguage();
|
||||||
$content = $this->generateContent($language);
|
$content = $this->generateContent($language);
|
||||||
$title = $this->generateTitle($language);
|
$title = $this->generateTitle($language);
|
||||||
|
@ -24,12 +25,12 @@ final class PhabricatorPasteTestDataGenerator
|
||||||
$policy = $this->generatePolicy();
|
$policy = $this->generatePolicy();
|
||||||
$filephid = $paste_file->getPHID();
|
$filephid = $paste_file->getPHID();
|
||||||
$parentphid = $this->loadPhabrictorPastePHID();
|
$parentphid = $this->loadPhabrictorPastePHID();
|
||||||
$paste = id(new PhabricatorPaste())
|
$paste = PhabricatorPaste::initializeNewPaste($author)
|
||||||
->setParentPHID($parentphid)
|
->setParentPHID($parentphid)
|
||||||
->setAuthorPHID($authorphid)
|
|
||||||
->setTitle($title)
|
->setTitle($title)
|
||||||
->setLanguage($language)
|
->setLanguage($language)
|
||||||
->setViewPolicy($policy)
|
->setViewPolicy($policy)
|
||||||
|
->setEditPolicy($policy)
|
||||||
->setFilePHID($filephid)
|
->setFilePHID($filephid)
|
||||||
->save();
|
->save();
|
||||||
return $paste;
|
return $paste;
|
||||||
|
|
|
@ -92,7 +92,11 @@ final class PhabricatorPholioMockTestDataGenerator
|
||||||
$quantity = min($quantity, count($images));
|
$quantity = min($quantity, count($images));
|
||||||
|
|
||||||
if ($quantity) {
|
if ($quantity) {
|
||||||
foreach (array_rand($images, $quantity) as $random) {
|
$random_images = $quantity === 1 ?
|
||||||
|
array(array_rand($images, $quantity)) :
|
||||||
|
array_rand($images, $quantity);
|
||||||
|
|
||||||
|
foreach ($random_images as $random) {
|
||||||
$rand_images[] = $images[$random]->getPHID();
|
$rand_images[] = $images[$random]->getPHID();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,15 +9,13 @@ final class PhabricatorProjectTestDataGenerator
|
||||||
$title = $this->generateTitle();
|
$title = $this->generateTitle();
|
||||||
$author = $this->loadPhabrictorUser();
|
$author = $this->loadPhabrictorUser();
|
||||||
$author_phid = $author->getPHID();
|
$author_phid = $author->getPHID();
|
||||||
$project = id(new PhabricatorProject())
|
$project = PhabricatorProject::initializeNewProject($author)
|
||||||
->setName($title)
|
->setName($title);
|
||||||
->setAuthorPHID($author_phid);
|
|
||||||
|
|
||||||
$this->addTransaction(
|
$this->addTransaction(
|
||||||
PhabricatorProjectTransaction::TYPE_NAME,
|
PhabricatorProjectTransaction::TYPE_NAME,
|
||||||
$title);
|
$title);
|
||||||
$this->addTransaction(
|
$project->attachMemberPHIDs(
|
||||||
PhabricatorProjectTransaction::TYPE_MEMBERS,
|
|
||||||
$this->loadMembersWithAuthor($author_phid));
|
$this->loadMembersWithAuthor($author_phid));
|
||||||
$this->addTransaction(
|
$this->addTransaction(
|
||||||
PhabricatorProjectTransaction::TYPE_STATUS,
|
PhabricatorProjectTransaction::TYPE_STATUS,
|
||||||
|
@ -35,6 +33,7 @@ final class PhabricatorProjectTestDataGenerator
|
||||||
$editor = id(new PhabricatorProjectTransactionEditor())
|
$editor = id(new PhabricatorProjectTransactionEditor())
|
||||||
->setActor($author)
|
->setActor($author)
|
||||||
->setContentSource(PhabricatorContentSource::newConsoleSource())
|
->setContentSource(PhabricatorContentSource::newConsoleSource())
|
||||||
|
->setContinueOnNoEffect(true)
|
||||||
->applyTransactions($project, $this->xactions);
|
->applyTransactions($project, $this->xactions);
|
||||||
|
|
||||||
return $project->save();
|
return $project->save();
|
||||||
|
|
Loading…
Reference in a new issue