1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-02-22 11:39:03 +01:00

Add a lipsum generator for Conpherence Rooms

Summary: Builds a basic room generator for Conpherence, picks a random name, adds 10 random users to it, sets view and edit policy to all users.

Test Plan:
`bin/lipsum generate conpherence`

{F4928815}

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D17699
This commit is contained in:
Chad Little 2017-04-29 19:53:14 -07:00
parent d6bce34a5d
commit 608dd06151
4 changed files with 198 additions and 0 deletions

View file

@ -292,6 +292,7 @@ phutil_register_library_map(array(
'ConpherenceCreateThreadConduitAPIMethod' => 'applications/conpherence/conduit/ConpherenceCreateThreadConduitAPIMethod.php',
'ConpherenceDAO' => 'applications/conpherence/storage/ConpherenceDAO.php',
'ConpherenceDurableColumnView' => 'applications/conpherence/view/ConpherenceDurableColumnView.php',
'ConpherenceEditConduitAPIMethod' => 'applications/conpherence/conduit/ConpherenceEditConduitAPIMethod.php',
'ConpherenceEditEngine' => 'applications/conpherence/editor/ConpherenceEditEngine.php',
'ConpherenceEditor' => 'applications/conpherence/editor/ConpherenceEditor.php',
'ConpherenceFulltextQuery' => 'applications/conpherence/query/ConpherenceFulltextQuery.php',
@ -2390,6 +2391,8 @@ phutil_register_library_map(array(
'PhabricatorConpherenceNotificationsSetting' => 'applications/settings/setting/PhabricatorConpherenceNotificationsSetting.php',
'PhabricatorConpherencePreferencesSettingsPanel' => 'applications/settings/panel/PhabricatorConpherencePreferencesSettingsPanel.php',
'PhabricatorConpherenceProfileMenuItem' => 'applications/search/menuitem/PhabricatorConpherenceProfileMenuItem.php',
'PhabricatorConpherenceRoomContextFreeGrammar' => 'applications/conpherence/lipsum/PhabricatorConpherenceRoomContextFreeGrammar.php',
'PhabricatorConpherenceRoomTestDataGenerator' => 'applications/conpherence/lipsum/PhabricatorConpherenceRoomTestDataGenerator.php',
'PhabricatorConpherenceSoundSetting' => 'applications/settings/setting/PhabricatorConpherenceSoundSetting.php',
'PhabricatorConpherenceThreadPHIDType' => 'applications/conpherence/phid/PhabricatorConpherenceThreadPHIDType.php',
'PhabricatorConpherenceWidgetVisibleSetting' => 'applications/settings/setting/PhabricatorConpherenceWidgetVisibleSetting.php',
@ -5075,6 +5078,7 @@ phutil_register_library_map(array(
'ConpherenceCreateThreadConduitAPIMethod' => 'ConpherenceConduitAPIMethod',
'ConpherenceDAO' => 'PhabricatorLiskDAO',
'ConpherenceDurableColumnView' => 'AphrontTagView',
'ConpherenceEditConduitAPIMethod' => 'PhabricatorEditEngineAPIMethod',
'ConpherenceEditEngine' => 'PhabricatorEditEngine',
'ConpherenceEditor' => 'PhabricatorApplicationTransactionEditor',
'ConpherenceFulltextQuery' => 'PhabricatorOffsetPagedQuery',
@ -7489,6 +7493,8 @@ phutil_register_library_map(array(
'PhabricatorConpherenceNotificationsSetting' => 'PhabricatorSelectSetting',
'PhabricatorConpherencePreferencesSettingsPanel' => 'PhabricatorEditEngineSettingsPanel',
'PhabricatorConpherenceProfileMenuItem' => 'PhabricatorProfileMenuItem',
'PhabricatorConpherenceRoomContextFreeGrammar' => 'PhutilContextFreeGrammar',
'PhabricatorConpherenceRoomTestDataGenerator' => 'PhabricatorTestDataGenerator',
'PhabricatorConpherenceSoundSetting' => 'PhabricatorSelectSetting',
'PhabricatorConpherenceThreadPHIDType' => 'PhabricatorPHIDType',
'PhabricatorConpherenceWidgetVisibleSetting' => 'PhabricatorInternalSetting',

View file

@ -0,0 +1,19 @@
<?php
final class ConpherenceEditConduitAPIMethod
extends PhabricatorEditEngineAPIMethod {
public function getAPIMethodName() {
return 'conpherence.edit';
}
public function newEditEngine() {
return new ConpherenceEditEngine();
}
public function getMethodSummary() {
return pht(
'Apply transactions to create a new room or edit an existing one.');
}
}

View file

@ -0,0 +1,97 @@
<?php
final class PhabricatorConpherenceRoomContextFreeGrammar
extends PhutilContextFreeGrammar {
protected function getRules() {
return array(
'start' => array(
'[dept]',
'[dept]',
'[dept]',
'[dept]',
'[dept]',
'[dept]',
'[dept]',
'[dept] ([city])',
'[dept] ([city])',
'[dept] - [city]',
'[dept] - [room]',
'[dept] / [room]',
'[dept] [room]',
'[city] ([dept]) - [room]',
'[dept] ([city]) - [room]',
'[dept] ([city]) [room]',
),
'dept' => array(
'Eng',
'Engineering',
'User Interface',
'Design',
'Data Science',
'Database',
'Marketing',
'Content',
'Ads',
'Operations',
'Network Ops',
'Ops',
'Server Ops',
'IT',
'Information Technology',
'i18n',
'Internationalization',
'Human Resources',
'HR',
'Research & Development',
'R&D',
'Management',
'Directors',
'Managers',
'Support',
'Customer Support',
'Finance',
'Sales',
'Purchasing',
'Education',
'Hardware Engineering',
'Software',
'Supply Management',
'Logistics',
'Growth',
'Content Strategy',
'Developer Relations',
'Accounting',
'Production',
),
'city' => array(
'Palo Alto',
'Mtn View',
'Cupertino',
'Los Altos',
'Menlo Park',
'Santa Cruz',
'S.F.',
'San Francisco',
'Seattle',
'London',
'New York',
'Dublin',
'Tokyo',
),
'room' => array(
'General',
'Announcements',
'Staff',
'Interns',
'Managers',
'Book Club',
'Parking',
'Sports',
'Social',
'Commuting',
'For Sale',
'Parents@',
),
);
}
}

View file

@ -0,0 +1,76 @@
<?php
final class PhabricatorConpherenceRoomTestDataGenerator
extends PhabricatorTestDataGenerator {
const GENERATORKEY = 'conpherence';
public function getGeneratorName() {
return pht('Conpherence');
}
public function generateObject() {
$author = $this->loadRandomUser();
$name = $this->newRoomName();
$participants = array();
$participants[] = $this->loadRandomUser();
$participants[] = $this->loadRandomUser();
$participants[] = $this->loadRandomUser();
$participants[] = $this->loadRandomUser();
$participants[] = $this->loadRandomUser();
$participants[] = $this->loadRandomUser();
$participants[] = $this->loadRandomUser();
$participants[] = $this->loadRandomUser();
$participants[] = $this->loadRandomUser();
$participants[] = $this->loadRandomUser();
$rando_phids = array();
$rando_phids[] = $author->getPHID();
foreach ($participants as $actor) {
$rando_phids[] = $actor->getPHID();
}
$xactions = array();
$xactions[] = array(
'type' => 'name',
'value' => $name,
);
$xactions[] = array(
'type' => 'participants.set',
'value' => $rando_phids,
);
$xactions[] = array(
'type' => 'view',
'value' => 'users',
);
$xactions[] = array(
'type' => 'edit',
'value' => 'users',
);
$params = array(
'transactions' => $xactions,
);
$result = id(new ConduitCall('conpherence.edit', $params))
->setUser($author)
->execute();
return $result['object']['phid'];
}
protected function newRoomName() {
$generator = new PhabricatorConpherenceRoomContextFreeGrammar();
$name = $generator->generate();
return $name;
}
}