From: Krinkle Date: Mon, 30 Jan 2012 19:40:20 +0000 (+0000) Subject: [Xml::encodeJsVar] Change to match FormatJson::encode output X-Git-Tag: 1.31.0-rc.0~25001 X-Git-Url: http://git.cyclocoop.org/%22%20.%20%20%20%24self2%20.%20%20%20%22&var_mode_affiche=boucle?a=commitdiff_plain;h=6ebbb369a69a0c8cd05caf11ae05caf7e096512d;p=lhc%2Fweb%2Fwiklou.git [Xml::encodeJsVar] Change to match FormatJson::encode output - Pure whitespace change - In preparation to deprecate it in favor of FormatJson / json_encode --- diff --git a/includes/Xml.php b/includes/Xml.php index 010c0b2b70..7e5b3cdba9 100644 --- a/includes/Xml.php +++ b/includes/Xml.php @@ -630,7 +630,7 @@ class Xml { $s = '['; foreach ( $value as $elt ) { if ( $s != '[' ) { - $s .= ', '; + $s .= ','; } $s .= self::encodeJsVar( $elt ); } @@ -642,10 +642,10 @@ class Xml { $s = '{'; foreach ( (array)$value as $name => $elt ) { if ( $s != '{' ) { - $s .= ', '; + $s .= ','; } - $s .= '"' . self::escapeJsString( $name ) . '": ' . + $s .= '"' . self::escapeJsString( $name ) . '":' . self::encodeJsVar( $elt ); } $s .= '}'; diff --git a/tests/phpunit/includes/XmlTest.php b/tests/phpunit/includes/XmlTest.php index ea5ae48a9b..e9c531cc89 100644 --- a/tests/phpunit/includes/XmlTest.php +++ b/tests/phpunit/includes/XmlTest.php @@ -325,12 +325,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' ); @@ -338,7 +338,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' );