Fix for r96344: explicitly set $wgExtensionAssetsPath during tests
[lhc/web/wiklou.git] / tests / parser / parserTest.inc
index 55092cd..6d2b225 100644 (file)
@@ -78,7 +78,7 @@ class ParserTest {
         */
        public function __construct( $options = array() ) {
                # Only colorize output if stdout is a terminal.
-               $this->color = !wfIsWindows() && posix_isatty( 1 );
+               $this->color = !wfIsWindows() && Maintenance::posix_isatty( 1 );
 
                if ( isset( $options['color'] ) ) {
                        switch( $options['color'] ) {
@@ -136,13 +136,14 @@ class ParserTest {
                        $wgUser, $wgLang, $wgOut, $wgRequest, $wgStyleDirectory, $wgEnableParserCache,
                        $wgNamespaceAliases, $wgNamespaceProtection, $wgLocalFileRepo,
                        $parserMemc, $wgThumbnailScriptPath, $wgScriptPath,
-                       $wgArticlePath, $wgStyleSheetPath, $wgScript, $wgStylePath;
+                       $wgArticlePath, $wgStyleSheetPath, $wgScript, $wgStylePath, $wgExtensionAssetsPath;
 
                $wgScript = '/index.php';
                $wgScriptPath = '/';
                $wgArticlePath = '/wiki/$1';
                $wgStyleSheetPath = '/skins';
                $wgStylePath = '/skins';
+               $wgExtensionAssetsPath = '/extensions';
                $wgThumbnailScriptPath = false;
                $wgLocalFileRepo = array(
                        'class' => 'LocalRepo',
@@ -170,7 +171,7 @@ class ParserTest {
                $wgLang = $context->getLang();
                $wgOut = $context->getOutput();
                $wgParser = new StubObject( 'wgParser', $wgParserConf['class'], array( $wgParserConf ) );
-               $wgRequest = new WebRequest;
+               $wgRequest = $context->getRequest();
 
                if ( $wgStyleDirectory === false ) {
                        $wgStyleDirectory   = "$IP/skins";
@@ -185,8 +186,6 @@ class ParserTest {
                                        $options['setversion'] : SpecialVersion::getVersion();
                } elseif ( isset( $options['compare'] ) ) {
                        $this->recorder = new DbTestPreviewer( $this );
-               } elseif ( isset( $options['upload'] ) ) {
-                       $this->recorder = new RemoteTestRecorder( $this );
                } else {
                        $this->recorder = new TestRecorder( $this );
                }
@@ -445,7 +444,7 @@ class ParserTest {
                if ( isset( $opts['pst'] ) ) {
                        $out = $parser->preSaveTransform( $input, $title, $user, $options );
                } elseif ( isset( $opts['msg'] ) ) {
-                       $out = $parser->transformMsg( $input, $options );
+                       $out = $parser->transformMsg( $input, $options, $title );
                } elseif ( isset( $opts['section'] ) ) {
                        $section = $opts['section'];
                        $out = $parser->getSection( $input, $section );
@@ -454,8 +453,7 @@ class ParserTest {
                        $replace = $opts['replace'][1];
                        $out = $parser->replaceSection( $input, $section, $replace );
                } elseif ( isset( $opts['comment'] ) ) {
-                       $linker = $user->getSkin();
-                       $out = $linker->formatComment( $input, $title, $local );
+                       $out = Linker::formatComment( $input, $title, $local );
                } elseif ( isset( $opts['preload'] ) ) {
                        $out = $parser->getpreloadText( $input, $title, $options );
                } else {
@@ -691,7 +689,6 @@ class ParserTest {
                global $wgHooks;
 
                $wgHooks['ParserTestParser'][] = 'ParserTestParserHook::setup';
-               $wgHooks['ParserTestParser'][] = 'ParserTestStaticParserHook::setup';
                $wgHooks['ParserGetVariableValueTs'][] = 'ParserTest::getFakeTimestamp';
 
                MagicWord::clearCache();
@@ -903,9 +900,9 @@ class ParserTest {
                        return $dir;
                }
 
-               wfMkdirParents( $dir . '/3/3a' );
+               wfMkdirParents( $dir . '/3/3a', null, __METHOD__ );
                copy( "$IP/skins/monobook/headbg.jpg", "$dir/3/3a/Foobar.jpg" );
-               wfMkdirParents( $dir . '/0/09' );
+               wfMkdirParents( $dir . '/0/09', null, __METHOD__ );
                copy( "$IP/skins/monobook/headbg.jpg", "$dir/0/09/Bad.jpg" );
 
                return $dir;
@@ -1072,7 +1069,9 @@ class ParserTest {
                $shellInfile = wfEscapeShellArg($infile);
                $shellOutfile = wfEscapeShellArg($outfile);
 
-               $diff = wfIsWindows()
+               global $wgDiff3;
+               // we assume that people with diff3 also have usual diff
+               $diff = ( wfIsWindows() && !$wgDiff3 )
                        ? `fc $shellInfile $shellOutfile`
                        : `diff -au $shellInfile $shellOutfile`;
                unlink( $infile );
@@ -1138,14 +1137,13 @@ class ParserTest {
                $title = Title::newFromText( $name );
 
                if ( is_null( $title ) ) {
-                       wfDie( "invalid title ('$name' => '$title') at line $line\n" );
+                       throw new MWException( "invalid title ('$name' => '$title') at line $line\n" );
                }
 
                $aid = $title->getArticleID( Title::GAID_FOR_UPDATE );
 
                if ( $aid != 0 ) {
-                       debug_print_backtrace();
-                       wfDie( "duplicate article '$name' at line $line\n" );
+                       throw new MWException( "duplicate article '$name' at line $line\n" );
                }
 
                $art = new Article( $title );
@@ -1206,7 +1204,6 @@ class ParserTest {
         *
         * @param $text String: the text to tidy
         * @return String
-        * @static
         */
        private function tidy( $text ) {
                global $wgUseTidy;