Fixup r109698, add setter for $namespaceNames and use proper accessors in the tests.
authorChad Horohoe <demon@users.mediawiki.org>
Fri, 27 Jan 2012 13:00:26 +0000 (13:00 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Fri, 27 Jan 2012 13:00:26 +0000 (13:00 +0000)
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
tests/phpunit/includes/HtmlTest.php
tests/phpunit/includes/XmlTest.php

index 7b08891..adb9432 100644 (file)
@@ -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
index b5e88db..90ff763 100644 (file)
@@ -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;
index ea9bd7e..ea5ae48 100644 (file)
@@ -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() {