X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fcontent%2FJsonContentTest.php;h=de8e371ebf01048308a0ddb2113730f43984aab1;hb=5e9df2809a0b0f55e08d56dbbbc684a4122c3370;hp=8a9d2ab0850a9c0267af41f81fee2d78e8973a1e;hpb=f873b499650ef5d27570f9cb96d01d1477f9e089;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/content/JsonContentTest.php b/tests/phpunit/includes/content/JsonContentTest.php index 8a9d2ab085..de8e371ebf 100644 --- a/tests/phpunit/includes/content/JsonContentTest.php +++ b/tests/phpunit/includes/content/JsonContentTest.php @@ -1,28 +1,22 @@ setMwGlobals( 'wgWellFormedXml', true ); - } - public static function provideValidConstruction() { - return array( - array( 'foo', false, null ), - array( '[]', true, array() ), - array( '{}', true, (object)array() ), - array( '""', true, '' ), - array( '"0"', true, '0' ), - array( '"bar"', true, 'bar' ), - array( '0', true, '0' ), - array( '{ "0": "bar" }', true, (object)array( 'bar' ) ), - ); + return [ + [ 'foo', false, null ], + [ '[]', true, [] ], + [ '{}', true, (object)[] ], + [ '""', true, '' ], + [ '"0"', true, '0' ], + [ '"bar"', true, 'bar' ], + [ '0', true, '0' ], + [ '{ "0": "bar" }', true, (object)[ 'bar' ] ], + ]; } /** @@ -35,35 +29,35 @@ class JsonContentTest extends MediaWikiLangTestCase { } public static function provideDataToEncode() { - return array( - array( + return [ + [ // Round-trip empty array '[]', '[]', - ), - array( + ], + [ // Round-trip empty object '{}', '{}', - ), - array( + ], + [ // Round-trip empty array/object (nested) '{ "foo": {}, "bar": [] }', "{\n \"foo\": {},\n \"bar\": []\n}", - ), - array( + ], + [ '{ "foo": "bar" }', "{\n \"foo\": \"bar\"\n}", - ), - array( + ], + [ '{ "foo": 1000 }', "{\n \"foo\": 1000\n}", - ), - array( + ], + [ '{ "foo": 1000, "0": "bar" }', "{\n \"foo\": 1000,\n \"0\": \"bar\"\n}", - ), - ); + ], + ]; } /** @@ -105,45 +99,45 @@ class JsonContentTest extends MediaWikiLangTestCase { } public static function provideDataAndParserText() { - return array( - array( - array(), + return [ + [ + [], '
' . '' . '
Empty array
' - ), - array( - (object)array(), + ], + [ + (object)[], '' . '
Empty object
' - ), - array( - (object)array( 'foo' ), + ], + [ + (object)[ 'foo' ], '' . '
0"foo"
' - ), - array( - (object)array( 'foo', 'bar' ), + ], + [ + (object)[ 'foo', 'bar' ], '' . '
0"foo"
1"bar"
' - ), - array( - (object)array( 'baz' => 'foo', 'bar' ), + ], + [ + (object)[ 'baz' => 'foo', 'bar' ], '' . '
baz"foo"
0"bar"
' - ), - array( - (object)array( 'baz' => 1000, 'bar' ), + ], + [ + (object)[ 'baz' => 1000, 'bar' ], '' . '
baz1000
0"bar"
' - ), - array( - (object)array( '' ), + ], + [ + (object)[ '' ], '
0"' . '<script>alert("evil!")</script>"' . '
', - ), - ); + ], + ]; } /**