From c9097200314fe553d1dc7349360c4c6c3628410a Mon Sep 17 00:00:00 2001 From: Brian Wolff Date: Wed, 17 Aug 2011 00:46:58 +0000 Subject: [PATCH] Follow-up r94680 - fix unit tests. The way the magic variable unit tests are run looks a little sketchy to me... --- includes/parser/Parser.php | 9 +++++++++ tests/phpunit/includes/parser/MagicVariableTest.php | 2 ++ 2 files changed, 11 insertions(+) diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index fdce7fa2b0..dc039fd40e 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -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. diff --git a/tests/phpunit/includes/parser/MagicVariableTest.php b/tests/phpunit/includes/parser/MagicVariableTest.php index 3c8430952e..f70c764a03 100644 --- a/tests/phpunit/includes/parser/MagicVariableTest.php +++ b/tests/phpunit/includes/parser/MagicVariableTest.php @@ -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?)*/ -- 2.20.1