Differential D17419 Diff 41894 src/applications/maniphest/lipsum/PhabricatorManiphestTaskTestDataGenerator.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/maniphest/lipsum/PhabricatorManiphestTaskTestDataGenerator.php
<?php | <?php | ||||
final class PhabricatorManiphestTaskTestDataGenerator | final class PhabricatorManiphestTaskTestDataGenerator | ||||
extends PhabricatorTestDataGenerator { | extends PhabricatorTestDataGenerator { | ||||
public function getGeneratorName() { | public function getGeneratorName() { | ||||
return pht('Maniphest Tasks'); | return pht('Maniphest Tasks'); | ||||
} | } | ||||
public function generateObject() { | public function generateObject() { | ||||
$author_phid = $this->loadPhabrictorUserPHID(); | $author_phid = $this->loadPhabricatorUserPHID(); | ||||
$author = id(new PhabricatorUser()) | $author = id(new PhabricatorUser()) | ||||
->loadOneWhere('phid = %s', $author_phid); | ->loadOneWhere('phid = %s', $author_phid); | ||||
$task = ManiphestTask::initializeNewTask($author) | $task = ManiphestTask::initializeNewTask($author) | ||||
->setSubPriority($this->generateTaskSubPriority()) | ->setSubPriority($this->generateTaskSubPriority()) | ||||
->setTitle($this->generateTitle()); | ->setTitle($this->generateTitle()); | ||||
$content_source = $this->getLipsumContentSource(); | $content_source = $this->getLipsumContentSource(); | ||||
Show All 38 Lines | $editor = id(new ManiphestTransactionEditor()) | ||||
->setContinueOnMissingFields(true) | ->setContinueOnMissingFields(true) | ||||
->applyTransactions($task, $transactions); | ->applyTransactions($task, $transactions); | ||||
return $task; | return $task; | ||||
} | } | ||||
public function getCCPHIDs() { | public function getCCPHIDs() { | ||||
$ccs = array(); | $ccs = array(); | ||||
for ($i = 0; $i < rand(1, 4);$i++) { | for ($i = 0; $i < rand(1, 4);$i++) { | ||||
$ccs[] = $this->loadPhabrictorUserPHID(); | $ccs[] = $this->loadPhabricatorUserPHID(); | ||||
} | } | ||||
return $ccs; | return $ccs; | ||||
} | } | ||||
public function getProjectPHIDs() { | public function getProjectPHIDs() { | ||||
$projects = array(); | $projects = array(); | ||||
for ($i = 0; $i < rand(1, 4);$i++) { | for ($i = 0; $i < rand(1, 4);$i++) { | ||||
$project = $this->loadOneRandom('PhabricatorProject'); | $project = $this->loadOneRandom('PhabricatorProject'); | ||||
if ($project) { | if ($project) { | ||||
$projects[] = $project->getPHID(); | $projects[] = $project->getPHID(); | ||||
} | } | ||||
} | } | ||||
return $projects; | return $projects; | ||||
} | } | ||||
public function loadOwnerPHID() { | public function loadOwnerPHID() { | ||||
if (rand(0, 3) == 0) { | if (rand(0, 3) == 0) { | ||||
return null; | return null; | ||||
} else { | } else { | ||||
return $this->loadPhabrictorUserPHID(); | return $this->loadPhabricatorUserPHID(); | ||||
} | } | ||||
} | } | ||||
public function generateTitle() { | public function generateTitle() { | ||||
return id(new PhutilLipsumContextFreeGrammar()) | return id(new PhutilLipsumContextFreeGrammar()) | ||||
->generate(); | ->generate(); | ||||
} | } | ||||
Show All 26 Lines |