diff --git a/src/applications/badges/lipsum/PhabricatorBadgesBadgeTestDataGenerator.php b/src/applications/badges/lipsum/PhabricatorBadgesBadgeTestDataGenerator.php index 9b29ecb4f8..8d56e20fa3 100644 --- a/src/applications/badges/lipsum/PhabricatorBadgesBadgeTestDataGenerator.php +++ b/src/applications/badges/lipsum/PhabricatorBadgesBadgeTestDataGenerator.php @@ -1,71 +1,91 @@ loadRandomUser(); - list($name, $description) = $this->newLoot(); + list($name, $description, $quality, $icon) = $this->newLoot(); $xactions = array(); $xactions[] = array( 'type' => 'name', 'value' => $name, ); $xactions[] = array( 'type' => 'description', 'value' => $description, ); + $xactions[] = array( + 'type' => 'quality', + 'value' => (string)$quality, + ); + + $xactions[] = array( + 'type' => 'icon', + 'value' => $icon, + ); + $params = array( 'transactions' => $xactions, ); $result = id(new ConduitCall('badges.edit', $params)) ->setUser($author) ->execute(); return $result['object']['phid']; } private function newLoot() { $drop = id(new PhabricatorBadgesLootContextFreeGrammar()) ->generate(); $drop = preg_replace_callback( '/<(\d+)-(\d+)>/', array($this, 'rollDropValue'), $drop); $effect_pattern = '/\s*\(([^)]+)\)/'; $matches = null; if (preg_match_all($effect_pattern, $drop, $matches)) { $description = $matches[1]; $description = implode("\n", $description); } else { $description = ''; } $drop = preg_replace($effect_pattern, '', $drop); - return array($drop, $description); + $quality_map = PhabricatorBadgesQuality::getQualityMap(); + shuffle($quality_map); + $quality = head($quality_map); + $rarity = $quality['rarity']; + + $icon_map = id(new PhabricatorBadgesIconSet())->getIcons(); + shuffle($icon_map); + $icon_map = head($icon_map); + $icon = $icon_map->getKey(); + + return array($drop, $description, $rarity, $icon); } public function rollDropValue($matches) { $min = (int)$matches[1]; $max = (int)$matches[2]; return mt_rand($min, $max); } }