Merge "SI standards for time units"
[lhc/web/wiklou.git] / maintenance / preprocessorFuzzTest.php
index fbf3b93..49c7aee 100644 (file)
  * @ingroup Maintenance
  */
 
-require_once( dirname( __FILE__ ) . '/commandLine.inc' );
+require_once( __DIR__ . '/commandLine.inc' );
 
 $wgHooks['BeforeParserFetchTemplateAndtitle'][] = 'PPFuzzTester::templateHook';
 
 class PPFuzzTester {
-       var $hairs = array(
+       public $hairs = array(
                '[[', ']]', '{{', '{{', '}}', '}}', '{{{', '}}}',
                '<', '>', '<nowiki', '<gallery', '</nowiki>', '</gallery>', '<nOwIkI>', '</NoWiKi>',
                '<!--' , '-->',
@@ -39,12 +39,12 @@ class PPFuzzTester {
                // extensions
                // '<ref>', '</ref>', '<references/>',
        );
-       var $minLength = 0;
-       var $maxLength = 20;
-       var $maxTemplates = 5;
-       // var $outputTypes = array( 'OT_HTML', 'OT_WIKI', 'OT_PREPROCESS' );
-       var $entryPoints = array( 'testSrvus', 'testPst', 'testPreprocess' );
-       var $verbose = false;
+       public $minLength = 0;
+       public $maxLength = 20;
+       public $maxTemplates = 5;
+       // public $outputTypes = array( 'OT_HTML', 'OT_WIKI', 'OT_PREPROCESS' );
+       public $entryPoints = array( 'testSrvus', 'testPst', 'testPreprocess' );
+       public $verbose = false;
        static $currentTest = false;
 
        function execute() {
@@ -102,7 +102,6 @@ class PPFuzzTester {
                                file_put_contents( $filename, "Input:\n$testReport\n" );*/
                        }
                }
-               wfLogProfilingData();
        }
 
        function makeInputText( $max = false ) {
@@ -141,7 +140,7 @@ class PPFuzzTester {
 }
 
 class PPFuzzTest {
-       var $templates, $mainText, $title, $entryPoint, $output;
+       public $templates, $mainText, $title, $entryPoint, $output;
 
        function __construct( $tester ) {
                global $wgMaxSigChars;
@@ -155,6 +154,9 @@ class PPFuzzTest {
                $this->templates = array();
        }
 
+       /**
+        * @param $title Title
+        */
        function templateHook( $title ) {
                $titleText = $title->getPrefixedDBkey();
 
@@ -190,10 +192,10 @@ class PPFuzzTest {
                $wgUser->mFrom = 'name';
                $wgUser->ppfz_test = $this;
 
-               $options = new ParserOptions;
+               $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->getPrefixedText(), $options );
+               $this->output = call_user_func( array( $wgParser, $this->entryPoint ), $this->mainText, $this->title, $options );
                return $this->output;
        }
 
@@ -217,7 +219,7 @@ class PPFuzzTest {
 }
 
 class PPFuzzUser extends User {
-       var $ppfz_test;
+       public $ppfz_test, $mDataLoaded;
 
        function load() {
                if ( $this->mDataLoaded ) {
@@ -227,13 +229,13 @@ class PPFuzzUser extends User {
                $this->loadDefaults( $this->mName );
        }
 
-       function getOption( $option, $defaultOverride = '' ) {
-               if ( $option === 'fancysig' ) {
+       function getOption( $oname, $defaultOverride = null, $ignoreHidden = false ) {
+               if ( $oname === 'fancysig' ) {
                        return $this->ppfz_test->fancySig;
-               } elseif ( $option === 'nickname' ) {
+               } elseif ( $oname === 'nickname' ) {
                        return $this->ppfz_test->nickname;
                } else {
-                       return parent::getOption( $option, $defaultOverride );
+                       return parent::getOption( $oname, $defaultOverride, $ignoreHidden );
                }
        }
 }