From d9022f63880ce039446fba8364f68e656b7bf4cb Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 3 May 2012 13:01:35 +0200 Subject: Update to MediaWiki 1.19.0 --- tests/phpunit/includes/XmlTest.php | 99 ++++++++++++++++++++++++++++++++------ 1 file changed, 85 insertions(+), 14 deletions(-) (limited to 'tests/phpunit/includes/XmlTest.php') diff --git a/tests/phpunit/includes/XmlTest.php b/tests/phpunit/includes/XmlTest.php index a6058ef6..1d9361f2 100644 --- a/tests/phpunit/includes/XmlTest.php +++ b/tests/phpunit/includes/XmlTest.php @@ -2,19 +2,43 @@ class XmlTest extends MediaWikiTestCase { private static $oldLang; + private static $oldNamespaces; public function setUp() { - global $wgLang, $wgLanguageCode; - + global $wgLang, $wgContLang; + self::$oldLang = $wgLang; - $wgLanguageCode = 'en'; - $wgLang = Language::factory( $wgLanguageCode ); + $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, $wgLanguageCode; + global $wgLang, $wgContLang; $wgLang = self::$oldLang; - $wgLanguageCode = $wgLang->getCode(); + + $wgContLang->setNamespaces( self::$oldNamespaces ); } public function testExpandAttributes() { @@ -88,6 +112,9 @@ class XmlTest extends MediaWikiTestCase { $this->assertEquals( '', Xml::closeElement( 'element' ), 'closeElement() shortcut' ); } + /** + * @group Broken + */ public function testDateMenu( ) { $curYear = intval(gmdate('Y')); $prevYear = $curYear - 1; @@ -98,11 +125,10 @@ class XmlTest extends MediaWikiTestCase { $nextMonth = $curMonth + 1; if( $nextMonth == 13 ) { $nextMonth = 1; } - $this->assertEquals( ' ', - Xml::dateMenu( '', ''), + Xml::dateMenu( '', '' ), "Date menu with neither year or month" ); } + function testNamespaceSelector() { + $this->assertEquals( + '', + Xml::namespaceSelector(), + 'Basic namespace selector without custom options' + ); + $this->assertEquals( + '' . +' ', + Xml::namespaceSelector( $selected = '2', $all = 'all', $element_name = 'myname', $label = 'Select a namespace:' ), + 'Basic namespace selector with custom values' + ); + } + + # # textarea # @@ -255,12 +326,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' ); @@ -268,7 +339,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' ); -- cgit v1.2.2