assertEquals( $isValid, $obj->isValid() ); $this->assertEquals( $expected, $obj->getData()->getValue() ); } public static function provideDataToEncode() { return [ [ // Round-trip empty array '[]', '[]', ], [ // Round-trip empty object '{}', '{}', ], [ // Round-trip empty array/object (nested) '{ "foo": {}, "bar": [] }', "{\n\t\"foo\": {},\n\t\"bar\": []\n}", ], [ '{ "foo": "bar" }', "{\n\t\"foo\": \"bar\"\n}", ], [ '{ "foo": 1000 }', "{\n\t\"foo\": 1000\n}", ], [ '{ "foo": 1000, "0": "bar" }', "{\n\t\"foo\": 1000,\n\t\"0\": \"bar\"\n}", ], ]; } /** * @dataProvider provideDataToEncode */ public function testBeautifyJson( $input, $beautified ) { $obj = new JsonContent( $input ); $this->assertEquals( $beautified, $obj->beautifyJSON() ); } }