From c35b93d9b63d45507785fe3a07a524d7aff2c03f Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Fri, 4 Oct 2013 15:29:32 -0700 Subject: [PATCH] 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 --- .../maniphest/editor/ManiphestTransactionEditorPro.php | 3 +++ .../lipsum/PhabricatorManiphestTaskTestDataGenerator.php | 2 +- .../maniphest/storage/ManiphestTransaction.php | 1 + .../lipsum/PhabricatorPholioMockTestDataGenerator.php | 9 +++++++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/applications/maniphest/editor/ManiphestTransactionEditorPro.php b/src/applications/maniphest/editor/ManiphestTransactionEditorPro.php index ed20c3bf7d..abff759e5c 100644 --- a/src/applications/maniphest/editor/ManiphestTransactionEditorPro.php +++ b/src/applications/maniphest/editor/ManiphestTransactionEditorPro.php @@ -28,6 +28,9 @@ final class ManiphestTransactionEditorPro switch ($xaction->getTransactionType()) { case ManiphestTransaction::TYPE_PRIORITY: + if ($this->getIsNewObject()) { + return null; + } return (int)$object->getPriority(); case ManiphestTransaction::TYPE_STATUS: if ($this->getIsNewObject()) { diff --git a/src/applications/maniphest/lipsum/PhabricatorManiphestTaskTestDataGenerator.php b/src/applications/maniphest/lipsum/PhabricatorManiphestTaskTestDataGenerator.php index 1d07ffbd4c..bf3573cbed 100644 --- a/src/applications/maniphest/lipsum/PhabricatorManiphestTaskTestDataGenerator.php +++ b/src/applications/maniphest/lipsum/PhabricatorManiphestTaskTestDataGenerator.php @@ -49,7 +49,7 @@ final class PhabricatorManiphestTaskTestDataGenerator ->setContinueOnNoEffect(true) ->setContinueOnMissingFields(true) ->applyTransactions($task, $transactions); - return $task->save(); + return $task; } public function getCCPHIDs() { diff --git a/src/applications/maniphest/storage/ManiphestTransaction.php b/src/applications/maniphest/storage/ManiphestTransaction.php index da14398f36..76ecc2cc61 100644 --- a/src/applications/maniphest/storage/ManiphestTransaction.php +++ b/src/applications/maniphest/storage/ManiphestTransaction.php @@ -78,6 +78,7 @@ final class ManiphestTransaction switch ($this->getTransactionType()) { case self::TYPE_TITLE: case self::TYPE_DESCRIPTION: + case self::TYPE_PRIORITY: if ($this->getOldValue() === null) { return true; } else { diff --git a/src/applications/pholio/lipsum/PhabricatorPholioMockTestDataGenerator.php b/src/applications/pholio/lipsum/PhabricatorPholioMockTestDataGenerator.php index 232ae91caf..0f0299d280 100644 --- a/src/applications/pholio/lipsum/PhabricatorPholioMockTestDataGenerator.php +++ b/src/applications/pholio/lipsum/PhabricatorPholioMockTestDataGenerator.php @@ -92,9 +92,18 @@ final class PhabricatorPholioMockTestDataGenerator ->loadAllWhere("mimeType = %s", "image/jpeg"); $rand_images = array(); $quantity = rand(2, 10); + $quantity = min($quantity, count($images)); foreach (array_rand($images, $quantity) as $random) { $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; }