X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2FHtmlTest.php;h=999e0bb56c0d0a5de825d0745baf402f1d0a8d38;hb=214b37ff07f3fde89430297b2a857750a56ae205;hp=62094b64b5d3c5679ec189921b2bc0e61b7f7db3;hpb=8cea6e052c944bec3abe241463d6b86f9a706a3a;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/HtmlTest.php b/tests/phpunit/includes/HtmlTest.php index 62094b64b5..999e0bb56c 100644 --- a/tests/phpunit/includes/HtmlTest.php +++ b/tests/phpunit/includes/HtmlTest.php @@ -10,12 +10,12 @@ class HtmlTest extends MediaWikiTestCase { 'wgUseMediaWikiUIEverywhere' => false, ] ); - $langObj = Language::factory( 'en' ); + $contLangObj = Language::factory( 'en' ); // Hardcode namespaces during test runs, // so that html output based on existing namespaces // can be properly evaluated. - $langObj->setNamespaces( [ + $contLangObj->setNamespaces( [ -2 => 'Media', -1 => 'Special', 0 => '', @@ -35,19 +35,56 @@ class HtmlTest extends MediaWikiTestCase { 100 => 'Custom', 101 => 'Custom_talk', ] ); - $this->setUserLang( $langObj ); - $this->setContentLang( $langObj ); + $this->setContentLang( $contLangObj ); + + $userLangObj = Language::factory( 'es' ); + $userLangObj->setNamespaces( [ + -2 => "Medio", + -1 => "Especial", + 0 => "", + 1 => "Discusión", + 2 => "Usuario", + 3 => "Usuario discusión", + 4 => "Wiki", + 5 => "Wiki discusión", + 6 => "Archivo", + 7 => "Archivo discusión", + 8 => "MediaWiki", + 9 => "MediaWiki discusión", + 10 => "Plantilla", + 11 => "Plantilla discusión", + 12 => "Ayuda", + 13 => "Ayuda discusión", + 14 => "Categoría", + 15 => "Categoría discusión", + 100 => "Personalizado", + 101 => "Personalizado discusión", + ] ); + $this->setUserLang( $userLangObj ); + $this->restoreWarnings = false; } protected function tearDown() { + Language::factory( 'en' )->resetNamespaces(); + if ( $this->restoreWarnings ) { $this->restoreWarnings = false; Wikimedia\restoreWarnings(); } + parent::tearDown(); } + /** + * @expectedException PHPUnit_Framework_Error_Notice + * @expectedExceptionMessage given element name with space + * @covers Html::openElement + */ + public function testOpenElement() { + Html::openElement( 'span id="x"' ); + } + /** * @covers Html::element * @covers Html::rawElement @@ -175,7 +212,6 @@ class HtmlTest extends MediaWikiTestCase { } /** - * Test for Html::expandAttributes() * Please note it output a string prefixed with a space! * @covers Html::expandAttributes */ @@ -319,7 +355,7 @@ class HtmlTest extends MediaWikiTestCase { public function testNamespaceSelector() { $this->assertEquals( '' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . '' . "\n" . '' . "\n" . '' . "\n" . @@ -371,7 +407,7 @@ class HtmlTest extends MediaWikiTestCase { $this->assertEquals( '' . "\u{00A0}" . '' ); + + $this->assertEquals( + '', + Html::namespaceSelector( + [ 'in-user-lang' => true ] + ), + 'Basic namespace selector in user language' + ); } /** @@ -426,7 +489,7 @@ class HtmlTest extends MediaWikiTestCase { public function testCanDisableANamespaces() { $this->assertEquals( '