Changeset View
Changeset View
Standalone View
Standalone View
src/applications/lipsum/generator/PhabricatorTestDataGenerator.php
Show First 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | for ($ii = 0; $ii < $n; $ii++) { | ||||
$sum += mt_rand(1, $d); | $sum += mt_rand(1, $d); | ||||
} | } | ||||
$sum += $bonus; | $sum += $bonus; | ||||
return $sum; | return $sum; | ||||
} | } | ||||
protected function newEmptyTransaction() { | |||||
throw new PhutilMethodNotImplementedException(); | |||||
} | |||||
protected function newTransaction($type, $value, $metadata = array()) { | |||||
$xaction = $this->newEmptyTransaction() | |||||
->setTransactionType($type) | |||||
->setNewValue($value); | |||||
foreach ($metadata as $key => $value) { | |||||
$xaction->setMetadataValue($key, $value); | |||||
} | |||||
return $xaction; | |||||
} | |||||
public function loadOneRandom($classname) { | public function loadOneRandom($classname) { | ||||
try { | try { | ||||
return newv($classname, array()) | return newv($classname, array()) | ||||
->loadOneWhere('1 = 1 ORDER BY RAND() LIMIT 1'); | ->loadOneWhere('1 = 1 ORDER BY RAND() LIMIT 1'); | ||||
} catch (PhutilMissingSymbolException $ex) { | } catch (PhutilMissingSymbolException $ex) { | ||||
throw new PhutilMissingSymbolException( | throw new PhutilMissingSymbolException( | ||||
pht( | pht( | ||||
'Unable to load symbol %s: this class does not exit.', | 'Unable to load symbol %s: this class does not exit.', | ||||
$classname)); | $classname)); | ||||
} | } | ||||
} | } | ||||
public function loadPhabrictorUserPHID() { | public function loadPhabrictorUserPHID() { | ||||
return $this->loadOneRandom('PhabricatorUser')->getPHID(); | return $this->loadOneRandom('PhabricatorUser')->getPHID(); | ||||
} | } | ||||
public function loadPhabrictorUser() { | public function loadPhabrictorUser() { | ||||
return $this->loadOneRandom('PhabricatorUser'); | return $this->loadOneRandom('PhabricatorUser'); | ||||
} | } | ||||
} | } |