X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2FHtmlTest.php;h=5410644a4929e1998aa30b8661d7202010a985bc;hb=434015880aab5b155cc7edd6fcddf1883d0395eb;hp=070a02936fdbe7985e9f0eed0cf712694790a26a;hpb=a97139808acf244936a870fe8bf7ba3667795f3b;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/HtmlTest.php b/tests/phpunit/includes/HtmlTest.php index 070a02936f..5d83b7eb5b 100644 --- a/tests/phpunit/includes/HtmlTest.php +++ b/tests/phpunit/includes/HtmlTest.php @@ -1,6 +1,7 @@ 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 => '', @@ -34,8 +35,54 @@ 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"' ); } /** @@ -165,7 +212,6 @@ class HtmlTest extends MediaWikiTestCase { } /** - * Test for Html::expandAttributes() * Please note it output a string prefixed with a space! * @covers Html::expandAttributes */ @@ -270,7 +316,7 @@ class HtmlTest extends MediaWikiTestCase { /** * How do we handle duplicate keys in HTML attributes expansion? - * We could pass a "class" the values: 'GREEN' and array( 'GREEN' => false ) + * We could pass a "class" the values: 'GREEN' and [ 'GREEN' => false ] * The latter will take precedence. * * Feature added by r96188 @@ -309,7 +355,7 @@ class HtmlTest extends MediaWikiTestCase { public function testNamespaceSelector() { $this->assertEquals( '' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . '' . "\n" . '' . "\n" . '' . "\n" . @@ -361,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' + ); } /** @@ -408,6 +481,26 @@ class HtmlTest extends MediaWikiTestCase { ), 'Namespace selector namespace filtering.' ); + $this->assertEquals( + '', + Html::namespaceSelector( + [ 'exclude' => [ 0, 1, 3, 100, 101 ], 'all' => '' ] + ), + 'Namespace selector namespace filtering with empty custom "all" option.' + ); } /** @@ -416,7 +509,7 @@ class HtmlTest extends MediaWikiTestCase { public function testCanDisableANamespaces() { $this->assertEquals( '