HtmlTest: Perform multilingual tests
authorErik Bernhardson <ebernhardson@wikimedia.org>
Fri, 12 Oct 2018 18:23:02 +0000 (11:23 -0700)
committerErik Bernhardson <ebernhardson@wikimedia.org>
Fri, 12 Oct 2018 18:24:17 +0000 (11:24 -0700)
The tests here were only testing when user and content language
are the same, but the way things are rendered when they differ
is perhaps more interesting as it allows ensuring the two are used
in the correct places.

Change-Id: I357f50b082882fee485a95323d3a0a7cadb9a63c

tests/phpunit/includes/HtmlTest.php

index 62094b6..71e733b 100644 (file)
@@ -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,8 +35,33 @@ 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;
        }
 
@@ -319,7 +344,7 @@ class HtmlTest extends MediaWikiTestCase {
        public function testNamespaceSelector() {
                $this->assertEquals(
                        '<select id="namespace" name="namespace">' . "\n" .
-                               '<option value="0">(Main)</option>' . "\n" .
+                               '<option value="0">(Principal)</option>' . "\n" .
                                '<option value="1">Talk</option>' . "\n" .
                                '<option value="2">User</option>' . "\n" .
                                '<option value="3">User talk</option>' . "\n" .
@@ -343,8 +368,8 @@ class HtmlTest extends MediaWikiTestCase {
                $this->assertEquals(
                        '<label for="mw-test-namespace">Select a namespace:</label>' . "\u{00A0}" .
                                '<select id="mw-test-namespace" name="wpNamespace">' . "\n" .
-                               '<option value="all">all</option>' . "\n" .
-                               '<option value="0">(Main)</option>' . "\n" .
+                               '<option value="all">todos</option>' . "\n" .
+                               '<option value="0">(Principal)</option>' . "\n" .
                                '<option value="1">Talk</option>' . "\n" .
                                '<option value="2" selected="">User</option>' . "\n" .
                                '<option value="3">User talk</option>' . "\n" .
@@ -371,7 +396,7 @@ class HtmlTest extends MediaWikiTestCase {
                $this->assertEquals(
                        '<label for="namespace">Select a namespace:</label>' . "\u{00A0}" .
                                '<select id="namespace" name="namespace">' . "\n" .
-                               '<option value="0">(Main)</option>' . "\n" .
+                               '<option value="0">(Principal)</option>' . "\n" .
                                '<option value="1">Talk</option>' . "\n" .
                                '<option value="2">User</option>' . "\n" .
                                '<option value="3">User talk</option>' . "\n" .
@@ -426,7 +451,7 @@ class HtmlTest extends MediaWikiTestCase {
        public function testCanDisableANamespaces() {
                $this->assertEquals(
                        '<select id="namespace" name="namespace">' . "\n" .
-                               '<option disabled="" value="0">(Main)</option>' . "\n" .
+                               '<option disabled="" value="0">(Principal)</option>' . "\n" .
                                '<option disabled="" value="1">Talk</option>' . "\n" .
                                '<option disabled="" value="2">User</option>' . "\n" .
                                '<option disabled="" value="3">User talk</option>' . "\n" .