From e8da212569bd910d9d6521b1e0c356bfdcf4db69 Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Fri, 27 Jan 2012 13:00:26 +0000 Subject: [PATCH] Fixup r109698, add setter for $namespaceNames and use proper accessors in the tests. Since we're here: nothing uses $namespaceNames, $mNamespaceIds or $namespaceAliases outside of this class (core or extensions) so lets make it protected. --- languages/Language.php | 13 ++++++++++--- tests/phpunit/includes/HtmlTest.php | 8 ++++---- tests/phpunit/includes/XmlTest.php | 9 +++++---- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/languages/Language.php b/languages/Language.php index 7b08891de7..adb9432887 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -63,11 +63,10 @@ class Language { var $mMagicExtensions = array(), $mMagicHookDone = false; private $mHtmlCode = null; - var $mNamespaceIds, $namespaceAliases; var $dateFormatStrings = array(); var $mExtendedSpecialPageAliases; - public $namespaceNames; + protected $namespaceNames, $mNamespaceIds, $namespaceAliases; /** * ReplacementArray object caches @@ -331,7 +330,7 @@ class Language { /** * @return array */ - function getNamespaces() { + public function getNamespaces() { if ( is_null( $this->namespaceNames ) ) { global $wgMetaNamespace, $wgMetaNamespaceTalk, $wgExtraNamespaces; @@ -364,6 +363,14 @@ class Language { } return $this->namespaceNames; } + + /** + * Arbitrarily set all of the namespace names at once. Mainly used for testing + * @param $namespaces Array of namespaces (id => name) + */ + public function setNamespaces( array $namespaces ) { + $this->namespaceNames = $namespaces; + } /** * A convenience function that returns the same thing as diff --git a/tests/phpunit/includes/HtmlTest.php b/tests/phpunit/includes/HtmlTest.php index b5e88db49c..90ff763524 100644 --- a/tests/phpunit/includes/HtmlTest.php +++ b/tests/phpunit/includes/HtmlTest.php @@ -12,7 +12,7 @@ class HtmlTest extends MediaWikiTestCase { self::$oldLang = $wgLang; self::$oldContLang = $wgContLang; - self::$oldNamespaces = $wgContLang->namespaceNames; + self::$oldNamespaces = $wgContLang->getNamespaces(); self::$oldLanguageCode = $wgLanguageCode; $wgLanguageCode = 'en'; @@ -21,7 +21,7 @@ class HtmlTest extends MediaWikiTestCase { // Hardcode namespaces during test runs, // so that html output based on existing namespaces // can be properly evaluated. - $wgContLang->namespaceNames = array( + $wgContLang->setNamespaces( array( -2 => 'Media', -1 => 'Special', 0 => '', @@ -38,13 +38,13 @@ class HtmlTest extends MediaWikiTestCase { 11 => 'Template_talk', 100 => 'Custom', 101 => 'Custom_talk', - ); + ) ); } public function tearDown() { global $wgLang, $wgContLang, $wgLanguageCode; - $wgContLang->namespaceNames = self::$oldNamespaces; + $wgContLang->setNamespaces( self::$oldNamespaces ); $wgLang = self::$oldLang; $wgContLang = self::$oldContLang; $wgLanguageCode = self::$oldLanguageCode; diff --git a/tests/phpunit/includes/XmlTest.php b/tests/phpunit/includes/XmlTest.php index ea9bd7e918..ea5ae48a9b 100644 --- a/tests/phpunit/includes/XmlTest.php +++ b/tests/phpunit/includes/XmlTest.php @@ -13,8 +13,8 @@ class XmlTest extends MediaWikiTestCase { // Hardcode namespaces during test runs, // so that html output based on existing namespaces // can be properly evaluated. - self::$oldNamespaces = $wgContLang->namespaceNames; - $wgContLang->namespaceNames = array( + self::$oldNamespaces = $wgContLang->getNamespaces(); + $wgContLang->setNamespaces( array( -2 => 'Media', -1 => 'Special', 0 => '', @@ -31,13 +31,14 @@ class XmlTest extends MediaWikiTestCase { 11 => 'Template_talk', 100 => 'Custom', 101 => 'Custom_talk', - ); + ) ); } public function tearDown() { global $wgLang, $wgContLang; $wgLang = self::$oldLang; - $wgContLang->namespaceNames = self::$oldNamespaces; + + $wgContLang->setNamespaces( self::$oldNamespaces ); } public function testExpandAttributes() { -- 2.20.1