1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 01:08:50 +02: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:
Mihir Kedia 2015-07-07 05:32:54 -07:00 committed by epriestley
parent 6d404c8219
commit 6a3c1ba05c
3 changed files with 13 additions and 9 deletions

View file

@ -10,7 +10,8 @@ final class PhabricatorPasteTestDataGenerator
);
public function generate() {
$authorphid = $this->loadPhabrictorUserPHID();
$author = $this->loadPhabrictorUser();
$authorphid = $author->getPHID();
$language = $this->generateLanguage();
$content = $this->generateContent($language);
$title = $this->generateTitle($language);
@ -24,12 +25,12 @@ final class PhabricatorPasteTestDataGenerator
$policy = $this->generatePolicy();
$filephid = $paste_file->getPHID();
$parentphid = $this->loadPhabrictorPastePHID();
$paste = id(new PhabricatorPaste())
$paste = PhabricatorPaste::initializeNewPaste($author)
->setParentPHID($parentphid)
->setAuthorPHID($authorphid)
->setTitle($title)
->setLanguage($language)
->setViewPolicy($policy)
->setEditPolicy($policy)
->setFilePHID($filephid)
->save();
return $paste;

View file

@ -92,7 +92,11 @@ final class PhabricatorPholioMockTestDataGenerator
$quantity = min($quantity, count($images));
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();
}
}

View file

@ -9,15 +9,13 @@ final class PhabricatorProjectTestDataGenerator
$title = $this->generateTitle();
$author = $this->loadPhabrictorUser();
$author_phid = $author->getPHID();
$project = id(new PhabricatorProject())
->setName($title)
->setAuthorPHID($author_phid);
$project = PhabricatorProject::initializeNewProject($author)
->setName($title);
$this->addTransaction(
PhabricatorProjectTransaction::TYPE_NAME,
$title);
$this->addTransaction(
PhabricatorProjectTransaction::TYPE_MEMBERS,
$project->attachMemberPHIDs(
$this->loadMembersWithAuthor($author_phid));
$this->addTransaction(
PhabricatorProjectTransaction::TYPE_STATUS,
@ -35,6 +33,7 @@ final class PhabricatorProjectTestDataGenerator
$editor = id(new PhabricatorProjectTransactionEditor())
->setActor($author)
->setContentSource(PhabricatorContentSource::newConsoleSource())
->setContinueOnNoEffect(true)
->applyTransactions($project, $this->xactions);
return $project->save();