Page MenuHomePhabricator

D19534.diff
No OneTemporary

D19534.diff

diff --git a/src/applications/differential/lipsum/PhabricatorDifferentialRevisionTestDataGenerator.php b/src/applications/differential/lipsum/PhabricatorDifferentialRevisionTestDataGenerator.php
--- a/src/applications/differential/lipsum/PhabricatorDifferentialRevisionTestDataGenerator.php
+++ b/src/applications/differential/lipsum/PhabricatorDifferentialRevisionTestDataGenerator.php
@@ -48,10 +48,12 @@
public function generateDiff($author) {
$paste_generator = new PhabricatorPasteTestDataGenerator();
- $languages = $paste_generator->supportedLanguages;
- $lang = array_rand($languages);
- $code = $paste_generator->generateContent($lang);
- $altcode = $paste_generator->generateContent($lang);
+ $languages = $paste_generator->getSupportedLanguages();
+ $language = array_rand($languages);
+ $spec = $languages[$language];
+
+ $code = $paste_generator->generateContent($spec);
+ $altcode = $paste_generator->generateContent($spec);
$newcode = $this->randomlyModify($code, $altcode);
$diff = id(new PhabricatorDifferenceEngine())
->generateRawDiffFromFileContent($code, $newcode);
diff --git a/src/applications/paste/lipsum/PhabricatorPasteTestDataGenerator.php b/src/applications/paste/lipsum/PhabricatorPasteTestDataGenerator.php
--- a/src/applications/paste/lipsum/PhabricatorPasteTestDataGenerator.php
+++ b/src/applications/paste/lipsum/PhabricatorPasteTestDataGenerator.php
@@ -22,9 +22,11 @@
PhabricatorPasteTitleTransaction::TRANSACTIONTYPE,
$name);
- $xactions[] = $this->newTransaction(
- PhabricatorPasteLanguageTransaction::TRANSACTIONTYPE,
- $language);
+ if (strlen($language) > 0) {
+ $xactions[] = $this->newTransaction(
+ PhabricatorPasteLanguageTransaction::TRANSACTIONTYPE,
+ $language);
+ }
$xactions[] = $this->newTransaction(
PhabricatorPasteContentTransaction::TRANSACTIONTYPE,
@@ -43,17 +45,29 @@
return new PhabricatorPasteTransaction();
}
- private function newPasteContent() {
- $languages = array(
- 'txt' => array(),
- 'php' => array(
- 'content' => 'PhutilPHPCodeSnippetContextFreeGrammar',
- ),
- 'java' => array(
- 'content' => 'PhutilJavaCodeSnippetContextFreeGrammar',
- ),
- );
+ public function getSupportedLanguages() {
+ return array(
+ 'php' => array(
+ 'content' => 'PhutilPHPCodeSnippetContextFreeGrammar',
+ ),
+ 'java' => array(
+ 'content' => 'PhutilJavaCodeSnippetContextFreeGrammar',
+ ),
+ );
+ }
+
+ public function generateContent($spec) {
+ $content_generator = idx($spec, 'content');
+ if (!$content_generator) {
+ $content_generator = 'PhutilLipsumContextFreeGrammar';
+ }
+ return newv($content_generator, array())
+ ->generateSeveral($this->roll(4, 12, 10));
+ }
+
+ private function newPasteContent() {
+ $languages = $this->getSupportedLanguages();
$language = array_rand($languages);
$spec = $languages[$language];
@@ -62,16 +76,10 @@
$title_generator = 'PhabricatorPasteFilenameContextFreeGrammar';
}
- $content_generator = idx($spec, 'content');
- if (!$content_generator) {
- $content_generator = 'PhutilLipsumContextFreeGrammar';
- }
-
$title = newv($title_generator, array())
->generate();
- $content = newv($content_generator, array())
- ->generateSeveral($this->roll(4, 12, 10));
+ $content = $this->generateContent($spec);
// Usually add the language as a suffix.
if ($this->roll(1, 20) > 2) {

File Metadata

Mime Type
text/plain
Expires
Wed, Mar 26, 5:40 AM (1 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7554615
Default Alt Text
D19534.diff (3 KB)

Event Timeline