X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FpreprocessorFuzzTest.php;h=9155623f100defd8b5520b140ef497a63c978c8c;hb=8585af15ed8b07386f7ae1daac3bd90165600569;hp=0a1a9f6f117ba8924d4fbc41c3f5bba876120ae3;hpb=117424d9e57256ffb1c27f17ba6eb004d3944ce1;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/preprocessorFuzzTest.php b/maintenance/preprocessorFuzzTest.php index 0a1a9f6f11..9155623f10 100644 --- a/maintenance/preprocessorFuzzTest.php +++ b/maintenance/preprocessorFuzzTest.php @@ -21,7 +21,7 @@ * @ingroup Maintenance */ -require_once( __DIR__ . '/commandLine.inc' ); +require_once __DIR__ . '/commandLine.inc'; $wgHooks['BeforeParserFetchTemplateAndtitle'][] = 'PPFuzzTester::templateHook'; @@ -45,7 +45,8 @@ class PPFuzzTester { // public $outputTypes = array( 'OT_HTML', 'OT_WIKI', 'OT_PREPROCESS' ); public $entryPoints = array( 'testSrvus', 'testPst', 'testPreprocess' ); public $verbose = false; - static $currentTest = false; + + private static $currentTest = false; function execute() { if ( !file_exists( 'results' ) ) { @@ -120,6 +121,7 @@ class PPFuzzTester { // It's done by the MW UI, so it's a reasonably legitimate thing to do. global $wgContLang; $s = $wgContLang->normalize( $s ); + return $s; } @@ -135,7 +137,8 @@ class PPFuzzTester { function pickEntryPoint() { $count = count( $this->entryPoints ); - return $this->entryPoints[ mt_rand( 0, $count - 1 ) ]; + + return $this->entryPoints[mt_rand( 0, $count - 1 )]; } } @@ -155,7 +158,7 @@ class PPFuzzTest { } /** - * @param $title Title + * @param Title $title */ function templateHook( $title ) { $titleText = $title->getPrefixedDBkey(); @@ -181,6 +184,7 @@ class PPFuzzTest { 'text' => $text, 'finalTitle' => $finalTitle ); } + return $this->templates[$titleText]; } @@ -195,7 +199,13 @@ class PPFuzzTest { $options = ParserOptions::newFromUser( $wgUser ); $options->setTemplateCallback( array( $this, 'templateHook' ) ); $options->setTimestamp( wfTimestampNow() ); - $this->output = call_user_func( array( $wgParser, $this->entryPoint ), $this->mainText, $this->title, $options ); + $this->output = call_user_func( + array( $wgParser, $this->entryPoint ), + $this->mainText, + $this->title, + $options + ); + return $this->output; } @@ -203,7 +213,8 @@ class PPFuzzTest { $s = "Title: " . $this->title->getPrefixedDBkey() . "\n" . // "Output type: {$this->outputType}\n" . "Entry point: {$this->entryPoint}\n" . - "User: " . ( $this->fancySig ? 'fancy' : 'no-fancy' ) . ' ' . var_export( $this->nickname, true ) . "\n" . + "User: " . ( $this->fancySig ? 'fancy' : 'no-fancy' ) . + ' ' . var_export( $this->nickname, true ) . "\n" . "Main text: " . var_export( $this->mainText, true ) . "\n"; foreach ( $this->templates as $titleText => $template ) { $finalTitle = $template['finalTitle']; @@ -214,6 +225,7 @@ class PPFuzzTest { } } $s .= "Output: " . var_export( $this->output, true ) . "\n"; + return $s; } }