Deprecate Parser implementation methods (will be private in next release)
[lhc/web/wiklou.git] / maintenance / preprocessorFuzzTest.php
index e57e977..bdc955b 100644 (file)
@@ -23,6 +23,8 @@
 
 use MediaWiki\MediaWikiServices;
 
+use Wikimedia\TestingAccessWrapper;
+
 $optionsWithoutArgs = [ 'verbose' ];
 require_once __DIR__ . '/commandLine.inc';
 
@@ -46,7 +48,7 @@ class PPFuzzTester {
        public $maxLength = 20;
        public $maxTemplates = 5;
        // public $outputTypes = [ 'OT_HTML', 'OT_WIKI', 'OT_PREPROCESS' ];
-       public $entryPoints = [ 'testSrvus', 'testPst', 'testPreprocess' ];
+       public $entryPoints = [ 'fuzzTestSrvus', 'fuzzTestPst', 'fuzzTestPreprocess' ];
        public $verbose = false;
 
        /**
@@ -72,7 +74,7 @@ class PPFuzzTester {
                                $passed = 'passed';
                        } catch ( Exception $e ) {
                                $testReport = self::$currentTest->getReport();
-                               $exceptionReport = $e->getText();
+                               $exceptionReport = $e instanceof MWException ? $e->getText() : (string)$e;
                                $hash = md5( $testReport );
                                file_put_contents( "results/ppft-$hash.in", serialize( self::$currentTest ) );
                                file_put_contents( "results/ppft-$hash.fail",
@@ -150,6 +152,16 @@ class PPFuzzTester {
 class PPFuzzTest {
        public $templates, $mainText, $title, $entryPoint, $output;
 
+       /** @var PPFuzzTester */
+       private $parent;
+       /** @var string */
+       public $nickname;
+       /** @var bool */
+       public $fancySig;
+
+       /**
+        * @param PPFuzzTester $tester
+        */
        function __construct( $tester ) {
                global $wgMaxSigChars;
                $this->parent = $tester;
@@ -206,7 +218,9 @@ class PPFuzzTest {
                $options->setTemplateCallback( [ $this, 'templateHook' ] );
                $options->setTimestamp( wfTimestampNow() );
                $this->output = call_user_func(
-                       [ MediaWikiServices::getInstance()->getParser(), $this->entryPoint ],
+                       [ TestingAccessWrapper::newFromObject(
+                               MediaWikiServices::getInstance()->getParser()
+                       ), $this->entryPoint ],
                        $this->mainText,
                        $this->title,
                        $options