Merge "[LockManager] Cleaned up DBLockManager and reduced code duplication."
[lhc/web/wiklou.git] / tests / phpunit / includes / XmlTest.php
index f722dfc..93ed3dc 100644 (file)
@@ -2,17 +2,43 @@
 
 class XmlTest extends MediaWikiTestCase {
        private static $oldLang;
+       private static $oldNamespaces;
 
        public function setUp() {
-               global $wgLang;
+               global $wgLang, $wgContLang;
 
                self::$oldLang = $wgLang;
                $wgLang = Language::factory( 'en' );
+
+               // Hardcode namespaces during test runs,
+               // so that html output based on existing namespaces
+               // can be properly evaluated.
+               self::$oldNamespaces = $wgContLang->getNamespaces();
+               $wgContLang->setNamespaces( array(
+                       -2 => 'Media',
+                       -1 => 'Special',
+                       0  => '',
+                       1  => 'Talk',
+                       2  => 'User',
+                       3  => 'User_talk',
+                       4  => 'MyWiki',
+                       5  => 'MyWiki_Talk',
+                       6  => 'File',
+                       7  => 'File_talk',
+                       8  => 'MediaWiki',
+                       9  => 'MediaWiki_talk',
+                       10  => 'Template',
+                       11  => 'Template_talk',
+                       100  => 'Custom',
+                       101  => 'Custom_talk',
+               ) );
        }
 
        public function tearDown() {
-               global $wgLang;
+               global $wgLang, $wgContLang;
                $wgLang = self::$oldLang;
+               
+               $wgContLang->setNamespaces( self::$oldNamespaces );
        }
 
        public function testExpandAttributes() {
@@ -225,6 +251,15 @@ class XmlTest extends MediaWikiTestCase {
                );
        }
 
+       function testLanguageSelector() {
+               $select = Xml::languageSelector( 'en', true, null,
+                       array( 'id' => 'testlang' ), wfMessage( 'yourlanguage' ) );
+               $this->assertEquals(
+                       '<label for="testlang">Language:</label>',
+                       $select[0]
+               );
+       }
+
        #
        # JS
        #
@@ -254,12 +289,12 @@ class XmlTest extends MediaWikiTestCase {
 
        function testEncodeJsVarArray() {
                $this->assertEquals(
-                       '["a", 1]',
+                       '["a",1]',
                        Xml::encodeJsVar( array( 'a', 1 ) ),
                        'encodeJsVar() with array'
                );
                $this->assertEquals(
-                       '{"a": "a", "b": 1}',
+                       '{"a":"a","b":1}',
                        Xml::encodeJsVar( array( 'a' => 'a', 'b' => 1 ) ),
                        'encodeJsVar() with associative array'
                );
@@ -267,7 +302,7 @@ class XmlTest extends MediaWikiTestCase {
 
        function testEncodeJsVarObject() {
                $this->assertEquals(
-                       '{"a": "a", "b": 1}',
+                       '{"a":"a","b":1}',
                        Xml::encodeJsVar( (object)array( 'a' => 'a', 'b' => 1 ) ),
                        'encodeJsVar() with object'
                );