1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 09:18:48 +02:00

lipsum - tighten up some test data generation

Summary:
maniphest tasks were fataling with priority 0 before making sure to add the return null if new object trick to the maniphest pro editor.

pholio had a problem where if you had no jpegs you were walking off array_rand. tighten the math and then just return a built-in if no uploaded user images could be found. Fixes T3889.

Test Plan: bin/lipsum generate for a few minutes and no errors

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran

Maniphest Tasks: T3889

Differential Revision: https://secure.phabricator.com/D7222
This commit is contained in:
Bob Trahan 2013-10-04 15:29:32 -07:00
parent ee4bdb501b
commit c35b93d9b6
4 changed files with 14 additions and 1 deletions

View file

@ -28,6 +28,9 @@ final class ManiphestTransactionEditorPro
switch ($xaction->getTransactionType()) { switch ($xaction->getTransactionType()) {
case ManiphestTransaction::TYPE_PRIORITY: case ManiphestTransaction::TYPE_PRIORITY:
if ($this->getIsNewObject()) {
return null;
}
return (int)$object->getPriority(); return (int)$object->getPriority();
case ManiphestTransaction::TYPE_STATUS: case ManiphestTransaction::TYPE_STATUS:
if ($this->getIsNewObject()) { if ($this->getIsNewObject()) {

View file

@ -49,7 +49,7 @@ final class PhabricatorManiphestTaskTestDataGenerator
->setContinueOnNoEffect(true) ->setContinueOnNoEffect(true)
->setContinueOnMissingFields(true) ->setContinueOnMissingFields(true)
->applyTransactions($task, $transactions); ->applyTransactions($task, $transactions);
return $task->save(); return $task;
} }
public function getCCPHIDs() { public function getCCPHIDs() {

View file

@ -78,6 +78,7 @@ final class ManiphestTransaction
switch ($this->getTransactionType()) { switch ($this->getTransactionType()) {
case self::TYPE_TITLE: case self::TYPE_TITLE:
case self::TYPE_DESCRIPTION: case self::TYPE_DESCRIPTION:
case self::TYPE_PRIORITY:
if ($this->getOldValue() === null) { if ($this->getOldValue() === null) {
return true; return true;
} else { } else {

View file

@ -92,9 +92,18 @@ final class PhabricatorPholioMockTestDataGenerator
->loadAllWhere("mimeType = %s", "image/jpeg"); ->loadAllWhere("mimeType = %s", "image/jpeg");
$rand_images = array(); $rand_images = array();
$quantity = rand(2, 10); $quantity = rand(2, 10);
$quantity = min($quantity, count($images));
foreach (array_rand($images, $quantity) as $random) { foreach (array_rand($images, $quantity) as $random) {
$rand_images[] = $images[$random]->getPHID(); $rand_images[] = $images[$random]->getPHID();
} }
// this means you don't have any jpegs yet. we'll
// just use a builtin image
if (empty($rand_images)) {
$default = PhabricatorFile::loadBuiltin(
PhabricatorUser::getOmnipotentUser(),
'profile.png');
$rand_images[] = $default->getPHID();
}
return $rand_images; return $rand_images;
} }