Follow-up r94680 - fix unit tests.
authorBrian Wolff <bawolff@users.mediawiki.org>
Wed, 17 Aug 2011 00:46:58 +0000 (00:46 +0000)
committerBrian Wolff <bawolff@users.mediawiki.org>
Wed, 17 Aug 2011 00:46:58 +0000 (00:46 +0000)
The way the magic variable unit tests are run looks a little sketchy to me...

includes/parser/Parser.php
tests/phpunit/includes/parser/MagicVariableTest.php

index fdce7fa..dc039fd 100644 (file)
@@ -2660,6 +2660,15 @@ class Parser {
                global $wgContLang, $wgSitename, $wgServer;
                global $wgArticlePath, $wgScriptPath, $wgStylePath;
 
+               if ( is_null( $this->mTitle ) ) {
+                       // If no title set, bad things are going to happen
+                       // later. Title should always be set since this
+                       // should only be called in the middle of a parse
+                       // operation (but the unit-tests do funky stuff)
+                       throw new MWException( __METHOD__ . ' Should only be '
+                               . ' called while parsing (no title set)' );
+               }
+
                /**
                 * Some of these require message or data lookups and can be
                 * expensive to check many times.
index 3c84309..f70c764 100644 (file)
@@ -38,6 +38,8 @@ class MagicVariableTest extends MediaWikiTestCase {
 
                # initialize parser output
                $this->testParser->clearState();
+               # Needs a title to do magic word stuff
+               $this->testParser->setTitle( Title::newFromText( 'Tests' ) );
        }
 
        /** destroy parser (TODO: is it really neded?)*/