https://www.mediawiki.org/wiki/Special:Code/MediaWiki/110118

Revision: 110118
Author:   demon
Date:     2012-01-27 13:00:26 +0000 (Fri, 27 Jan 2012)
Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/phase3/languages/Language.php
    trunk/phase3/tests/phpunit/includes/HtmlTest.php
    trunk/phase3/tests/phpunit/includes/XmlTest.php

Modified: trunk/phase3/languages/Language.php
===================================================================
--- trunk/phase3/languages/Language.php 2012-01-27 12:22:27 UTC (rev 110117)
+++ trunk/phase3/languages/Language.php 2012-01-27 13:00:26 UTC (rev 110118)
@@ -63,11 +63,10 @@
        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 @@
        /**
         * @return array
         */
-       function getNamespaces() {
+       public function getNamespaces() {
                if ( is_null( $this->namespaceNames ) ) {
                        global $wgMetaNamespace, $wgMetaNamespaceTalk, 
$wgExtraNamespaces;
 
@@ -364,6 +363,14 @@
                }
                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

Modified: trunk/phase3/tests/phpunit/includes/HtmlTest.php
===================================================================
--- trunk/phase3/tests/phpunit/includes/HtmlTest.php    2012-01-27 12:22:27 UTC 
(rev 110117)
+++ trunk/phase3/tests/phpunit/includes/HtmlTest.php    2012-01-27 13:00:26 UTC 
(rev 110118)
@@ -12,7 +12,7 @@
                
                self::$oldLang = $wgLang;
                self::$oldContLang = $wgContLang;
-               self::$oldNamespaces = $wgContLang->namespaceNames;
+               self::$oldNamespaces = $wgContLang->getNamespaces();
                self::$oldLanguageCode = $wgLanguageCode;
                
                $wgLanguageCode = 'en';
@@ -21,7 +21,7 @@
                // 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 @@
                        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;

Modified: trunk/phase3/tests/phpunit/includes/XmlTest.php
===================================================================
--- trunk/phase3/tests/phpunit/includes/XmlTest.php     2012-01-27 12:22:27 UTC 
(rev 110117)
+++ trunk/phase3/tests/phpunit/includes/XmlTest.php     2012-01-27 13:00:26 UTC 
(rev 110118)
@@ -13,8 +13,8 @@
                // 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 @@
                        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() {


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to