Removed Xml::escapeJsString()
[lhc/web/wiklou.git] / tests / phpunit / includes / XmlTest.php
index 382e3d8..18ff1f4 100644 (file)
@@ -9,7 +9,7 @@ class XmlTest extends MediaWikiTestCase {
                parent::setUp();
 
                $langObj = Language::factory( 'en' );
-               $langObj->setNamespaces( array(
+               $langObj->setNamespaces( [
                        -2 => 'Media',
                        -1 => 'Special',
                        0 => '',
@@ -26,12 +26,12 @@ class XmlTest extends MediaWikiTestCase {
                        11 => 'Template_talk',
                        100 => 'Custom',
                        101 => 'Custom_talk',
-               ) );
+               ] );
 
-               $this->setMwGlobals( array(
+               $this->setMwGlobals( [
                        'wgLang' => $langObj,
-                       'wgWellFormedXml' => true,
-               ) );
+                       'wgUseMediaWikiUIEverywhere' => false,
+               ] );
        }
 
        /**
@@ -41,7 +41,7 @@ class XmlTest extends MediaWikiTestCase {
                $this->assertNull( Xml::expandAttributes( null ),
                        'Converting a null list of attributes'
                );
-               $this->assertEquals( '', Xml::expandAttributes( array() ),
+               $this->assertEquals( '', Xml::expandAttributes( [] ),
                        'Converting an empty list of attributes'
                );
        }
@@ -113,7 +113,7 @@ class XmlTest extends MediaWikiTestCase {
        public function testElementAttributes() {
                $this->assertEquals(
                        '<element key="value" <>="&lt;&gt;">',
-                       Xml::element( 'element', array( 'key' => 'value', '<>' => '<>' ), null ),
+                       Xml::element( 'element', [ 'key' => 'value', '<>' => '<>' ], null ),
                        'Element attributes, keys are not escaped'
                );
        }
@@ -124,7 +124,7 @@ class XmlTest extends MediaWikiTestCase {
        public function testOpenElement() {
                $this->assertEquals(
                        '<element k="v">',
-                       Xml::openElement( 'element', array( 'k' => 'v' ) ),
+                       Xml::openElement( 'element', [ 'k' => 'v' ] ),
                        'openElement() shortcut'
                );
        }
@@ -152,9 +152,9 @@ class XmlTest extends MediaWikiTestCase {
 
                $this->assertEquals(
                        '<label for="year">From year (and earlier):</label> ' .
-                               '<input id="year" maxlength="4" size="7" type="number" value="2011" name="year" /> ' .
+                               '<input id="year" maxlength="4" size="7" type="number" value="2011" name="year"/> ' .
                                '<label for="month">From month (and earlier):</label> ' .
-                               '<select id="month" name="month" class="mw-month-selector">' .
+                               '<select name="month" id="month" class="mw-month-selector">' .
                                '<option value="-1">all</option>' . "\n" .
                                '<option value="1">January</option>' . "\n" .
                                '<option value="2" selected="">February</option>' . "\n" .
@@ -173,9 +173,9 @@ class XmlTest extends MediaWikiTestCase {
                );
                $this->assertEquals(
                        '<label for="year">From year (and earlier):</label> ' .
-                               '<input id="year" maxlength="4" size="7" type="number" value="2011" name="year" /> ' .
+                               '<input id="year" maxlength="4" size="7" type="number" value="2011" name="year"/> ' .
                                '<label for="month">From month (and earlier):</label> ' .
-                               '<select id="month" name="month" class="mw-month-selector">' .
+                               '<select name="month" id="month" class="mw-month-selector">' .
                                '<option value="-1">all</option>' . "\n" .
                                '<option value="1">January</option>' . "\n" .
                                '<option value="2">February</option>' . "\n" .
@@ -207,9 +207,9 @@ class XmlTest extends MediaWikiTestCase {
 
                $this->assertEquals(
                        '<label for="year">From year (and earlier):</label> ' .
-                               '<input id="year" maxlength="4" size="7" type="number" name="year" /> ' .
+                               '<input id="year" maxlength="4" size="7" type="number" name="year"/> ' .
                                '<label for="month">From month (and earlier):</label> ' .
-                               '<select id="month" name="month" class="mw-month-selector">' .
+                               '<select name="month" id="month" class="mw-month-selector">' .
                                '<option value="-1">all</option>' . "\n" .
                                '<option value="1">January</option>' . "\n" .
                                '<option value="2">February</option>' . "\n" .
@@ -267,27 +267,27 @@ class XmlTest extends MediaWikiTestCase {
        public function testLabelAttributeCanOnlyBeClassOrTitle() {
                $this->assertEquals(
                        '<label for="id">name</label>',
-                       Xml::label( 'name', 'id', array( 'generated' => true ) ),
+                       Xml::label( 'name', 'id', [ 'generated' => true ] ),
                        'label() can not be given a generated attribute'
                );
                $this->assertEquals(
                        '<label for="id" class="nice">name</label>',
-                       Xml::label( 'name', 'id', array( 'class' => 'nice' ) ),
+                       Xml::label( 'name', 'id', [ 'class' => 'nice' ] ),
                        'label() can get a class attribute'
                );
                $this->assertEquals(
                        '<label for="id" title="nice tooltip">name</label>',
-                       Xml::label( 'name', 'id', array( 'title' => 'nice tooltip' ) ),
+                       Xml::label( 'name', 'id', [ 'title' => 'nice tooltip' ] ),
                        'label() can get a title attribute'
                );
                $this->assertEquals(
                        '<label for="id" class="nice" title="nice tooltip">name</label>',
-                       Xml::label( 'name', 'id', array(
+                       Xml::label( 'name', 'id', [
                                        'generated' => true,
                                        'class' => 'nice',
                                        'title' => 'nice tooltip',
                                        'anotherattr' => 'value',
-                               )
+                               ]
                        ),
                        'label() skip all attributes but "class" and "title"'
                );
@@ -298,24 +298,13 @@ class XmlTest extends MediaWikiTestCase {
         */
        public function testLanguageSelector() {
                $select = Xml::languageSelector( 'en', true, null,
-                       array( 'id' => 'testlang' ), wfMessage( 'yourlanguage' ) );
+                       [ 'id' => 'testlang' ], wfMessage( 'yourlanguage' ) );
                $this->assertEquals(
                        '<label for="testlang">Language:</label>',
                        $select[0]
                );
        }
 
-       /**
-        * @covers Xml::escapeJsString
-        */
-       public function testEscapeJsStringSpecialChars() {
-               $this->assertEquals(
-                       '\\\\\r\n',
-                       Xml::escapeJsString( "\\\r\n" ),
-                       'escapeJsString() with special characters'
-               );
-       }
-
        /**
         * @covers Xml::encodeJsVar
         */
@@ -344,12 +333,12 @@ class XmlTest extends MediaWikiTestCase {
        public function testEncodeJsVarArray() {
                $this->assertEquals(
                        '["a",1]',
-                       Xml::encodeJsVar( array( 'a', 1 ) ),
+                       Xml::encodeJsVar( [ 'a', 1 ] ),
                        'encodeJsVar() with array'
                );
                $this->assertEquals(
                        '{"a":"a","b":1}',
-                       Xml::encodeJsVar( array( 'a' => 'a', 'b' => 1 ) ),
+                       Xml::encodeJsVar( [ 'a' => 'a', 'b' => 1 ] ),
                        'encodeJsVar() with associative array'
                );
        }
@@ -360,7 +349,7 @@ class XmlTest extends MediaWikiTestCase {
        public function testEncodeJsVarObject() {
                $this->assertEquals(
                        '{"a":"a","b":1}',
-                       Xml::encodeJsVar( (object)array( 'a' => 'a', 'b' => 1 ) ),
+                       Xml::encodeJsVar( (object)[ 'a' => 'a', 'b' => 1 ] ),
                        'encodeJsVar() with object'
                );
        }