Changeset View
Changeset View
Standalone View
Standalone View
src/applications/lipsum/generator/PhabricatorTestDataGenerator.php
Show All 39 Lines | protected function loadRandomUser() { | ||||
$user_phid = $this->loadRandomPHID(new PhabricatorUser()); | $user_phid = $this->loadRandomPHID(new PhabricatorUser()); | ||||
$user = null; | $user = null; | ||||
if ($user_phid) { | if ($user_phid) { | ||||
$user = id(new PhabricatorPeopleQuery()) | $user = id(new PhabricatorPeopleQuery()) | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->withPHIDs(array($user_phid)) | ->withPHIDs(array($user_phid)) | ||||
->needUserSettings(true) | |||||
->executeOne(); | ->executeOne(); | ||||
} | } | ||||
if (!$user) { | if (!$user) { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'Failed to load a random user. You may need to generate more '. | 'Failed to load a random user. You may need to generate more '. | ||||
'test users first.')); | 'test users first.')); | ||||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | abstract class PhabricatorTestDataGenerator extends Phobject { | ||||
public function loadPhabricatorUserPHID() { | public function loadPhabricatorUserPHID() { | ||||
return $this->loadOneRandom('PhabricatorUser')->getPHID(); | return $this->loadOneRandom('PhabricatorUser')->getPHID(); | ||||
} | } | ||||
public function loadPhabricatorUser() { | public function loadPhabricatorUser() { | ||||
return $this->loadOneRandom('PhabricatorUser'); | return $this->loadOneRandom('PhabricatorUser'); | ||||
} | } | ||||
} | } |