[Xml::encodeJsVar] Change to match FormatJson::encode output
authorKrinkle <krinkle@users.mediawiki.org>
Mon, 30 Jan 2012 19:40:20 +0000 (19:40 +0000)
committerKrinkle <krinkle@users.mediawiki.org>
Mon, 30 Jan 2012 19:40:20 +0000 (19:40 +0000)
- Pure whitespace change
- In preparation to deprecate it in favor of FormatJson / json_encode

includes/Xml.php
tests/phpunit/includes/XmlTest.php

index 010c0b2..7e5b3cd 100644 (file)
@@ -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 .= '}';
index ea5ae48..e9c531c 100644 (file)
@@ -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'
                );