aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/json/FormatJsonTest.php
diff options
context:
space:
mode:
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>2013-10-25 22:33:12 +0000
committerGerrit Code Review <gerrit@wikimedia.org>2013-10-25 22:33:12 +0000
commitc83d5d7864c299851e52c5098d45b9fff3ac0693 (patch)
tree84f7977783f7b705ccadee6c036f69e0fda8dd19 /tests/phpunit/includes/json/FormatJsonTest.php
parent1aeec323e8571d66072b50d95225ba8314300bf4 (diff)
parentb6a5bb484d90c6705bd1b010efcc2c1c18be1f34 (diff)
downloadmediawikicore-c83d5d7864c299851e52c5098d45b9fff3ac0693.tar.gz
mediawikicore-c83d5d7864c299851e52c5098d45b9fff3ac0693.zip
Merge "FormatJson: Remove whitespace from empty arrays and objects"
Diffstat (limited to 'tests/phpunit/includes/json/FormatJsonTest.php')
-rw-r--r--tests/phpunit/includes/json/FormatJsonTest.php14
1 files changed, 8 insertions, 6 deletions
diff --git a/tests/phpunit/includes/json/FormatJsonTest.php b/tests/phpunit/includes/json/FormatJsonTest.php
index 3eeaaed53338..8359f0d2e735 100644
--- a/tests/phpunit/includes/json/FormatJsonTest.php
+++ b/tests/phpunit/includes/json/FormatJsonTest.php
@@ -15,28 +15,30 @@ class FormatJsonTest extends MediaWikiTestCase {
123,
456,
),
+ // Nested json works without problems
'"7":["8",{"9":"10"}]',
+ // Whitespace clean up doesn't touch strings that look alike
+ "{\n\t\"emptyObject\": {\n\t},\n\t\"emptyArray\": [ ]\n}",
),
);
// 4 space indent, no trailing whitespace, no trailing linefeed
$json = '{
- "emptyObject": {
- },
- "emptyArray": [
- ],
+ "emptyObject": {},
+ "emptyArray": [],
"string": "foobar\\\\",
"filledArray": [
[
123,
456
],
- "\"7\":[\"8\",{\"9\":\"10\"}]"
+ "\"7\":[\"8\",{\"9\":\"10\"}]",
+ "{\n\t\"emptyObject\": {\n\t},\n\t\"emptyArray\": [ ]\n}"
]
}';
$json = str_replace( "\r", '', $json ); // Windows compat
- $this->assertSame( $json, str_replace("\n\n", "\n", FormatJson::encode( $obj, true ) ));
+ $this->assertSame( $json, FormatJson::encode( $obj, true ) );
}
public static function provideEncodeDefault() {