@@ -1139,14 +1139,14 @@ public function testEscJSonSpecialChars02() {
11391139 * @test
11401140 */
11411141 public function testFormat00 () {
1142- $ j = new Json ([],true );
1142+ $ j = new Json ([],null , null , true );
11431143 $ this ->assertEquals ("{ \r\n} " ,$ j .'' );
11441144 }
11451145 /**
11461146 * @test
11471147 */
11481148 public function testFormat01 () {
1149- $ j = new Json ([],true );
1149+ $ j = new Json ([],null , null , true );
11501150 $ j ->addBoolean ('hello ' );
11511151 $ this ->assertEquals ("{ \r\n"
11521152 .' "hello":true ' ."\r\n"
@@ -1156,7 +1156,7 @@ public function testFormat01() {
11561156 * @test
11571157 */
11581158 public function testFormat02 () {
1159- $ j = new Json ([],true );
1159+ $ j = new Json ([],null , null , true );
11601160 $ j ->addNumber ('hello ' ,66 );
11611161 $ this ->assertEquals ("{ \r\n"
11621162 .' "hello":66 ' ."\r\n"
@@ -1166,7 +1166,7 @@ public function testFormat02() {
11661166 * @test
11671167 */
11681168 public function testFormat03 () {
1169- $ j = new Json ([],true );
1169+ $ j = new Json ([],null , null , true );
11701170 $ j ->addString ('hello ' ,'world ' );
11711171 $ j ->addString ('hello2 ' ,'another string ' );
11721172 $ this ->assertEquals ("{ \r\n"
@@ -1178,7 +1178,7 @@ public function testFormat03() {
11781178 * @test
11791179 */
11801180 public function testFormat04 () {
1181- $ j = new Json ([],true );
1181+ $ j = new Json ([],null , null , true );
11821182 $ j ->addArray ('hello-arr ' ,[]);
11831183 $ this ->assertEquals ("{ \r\n"
11841184 .' "hello-arr":[ ' ."\r\n"
@@ -1189,7 +1189,7 @@ public function testFormat04() {
11891189 * @test
11901190 */
11911191 public function testFormat05 () {
1192- $ j = new Json ([],true );
1192+ $ j = new Json ([],null , null , true );
11931193 $ j ->addArray ('hello-arr ' ,[1 ,2 ,3 ,4 ]);
11941194 $ this ->assertEquals ("{ \r\n"
11951195 .' "hello-arr":[ ' ."\r\n"
@@ -1204,7 +1204,7 @@ public function testFormat05() {
12041204 * @test
12051205 */
12061206 public function testFormat06 () {
1207- $ j = new Json ([],true );
1207+ $ j = new Json ([],null , null , true );
12081208 $ j ->addArray ('hello-arr ' ,[[],["hello world " ]]);
12091209 $ this ->assertEquals ("{ \r\n"
12101210 .' "hello-arr":[ ' ."\r\n"
@@ -1220,7 +1220,7 @@ public function testFormat06() {
12201220 * @test
12211221 */
12221222 public function testFormat07 () {
1223- $ j = new Json ([],true );
1223+ $ j = new Json ([],null , null , true );
12241224 $ j ->addArray ('hello-arr ' ,[[],["hello world " ,["another sub " ,"with two elements " ]]]);
12251225 $ this ->assertEquals ("{ \r\n"
12261226 .' "hello-arr":[ ' ."\r\n"
@@ -1240,7 +1240,7 @@ public function testFormat07() {
12401240 * @test
12411241 */
12421242 public function testFormat08 () {
1243- $ j = new Json ([],true );
1243+ $ j = new Json ([],null , null , true );
12441244 $ j ->addArray ('hello-arr ' ,[],true );
12451245 $ this ->assertEquals ("{ \r\n"
12461246 .' "hello-arr":{ ' ."\r\n"
@@ -1251,7 +1251,7 @@ public function testFormat08() {
12511251 * @test
12521252 */
12531253 public function testFormat09 () {
1254- $ j = new Json ([],true );
1254+ $ j = new Json ([],null , null , true );
12551255 $ j ->addArray ('hello-arr ' ,[1 ,2 ,3 ,"hello mr ali " ],true );
12561256 $ this ->assertEquals ("{ \r\n"
12571257 .' "hello-arr":{ ' ."\r\n"
@@ -1266,7 +1266,7 @@ public function testFormat09() {
12661266 * @test
12671267 */
12681268 public function testFormat10 () {
1269- $ j = new Json ([],true );
1269+ $ j = new Json ([],null , null , true );
12701270 $ j ->addArray ('hello-arr ' ,["is-good " => "You are good " ,2 ,3 ,"hello mr ali " ,[],["a sub with element " ,"hello " => 'world ' ]],true );
12711271 $ this ->assertEquals ("{ \r\n"
12721272 .' "hello-arr":{ ' ."\r\n"
@@ -1287,7 +1287,7 @@ public function testFormat10() {
12871287 * @test
12881288 */
12891289 public function testFormat11 () {
1290- $ j = new Json ([],true );
1290+ $ j = new Json ([], null , null , true );
12911291 $ obj = new Obj1 ('Hello ' ,0 ,true ,null ,'he ' );
12921292 $ j ->addObject ('object ' ,$ obj );
12931293 $ this ->assertEquals ('{ ' ."\r\n"
@@ -1302,7 +1302,7 @@ public function testFormat11() {
13021302 * @test
13031303 */
13041304 public function testFormat12 () {
1305- $ j = new Json ([],true );
1305+ $ j = new Json ([], null , null , true );
13061306 $ obj = new Obj1 ('Hello ' ,0 ,true ,null ,'he ' );
13071307 $ j ->addArray ('array ' ,[$ obj ]);
13081308 $ this ->assertEquals ('{ ' ."\r\n"
@@ -1319,7 +1319,7 @@ public function testFormat12() {
13191319 * @test
13201320 */
13211321 public function testFormat13 () {
1322- $ j = new Json ([],true );
1322+ $ j = new Json ([], null , null , true );
13231323 $ obj = new Obj1 ('Hello ' ,0 ,true ,null ,'he ' );
13241324 $ j ->addArray ('array ' ,[$ obj ],true );
13251325 $ this ->assertEquals ('{ ' ."\r\n"
@@ -1336,7 +1336,7 @@ public function testFormat13() {
13361336 * @test
13371337 */
13381338 public function testFormat14 () {
1339- $ j = new Json ([],true );
1339+ $ j = new Json ([], null , null , true );
13401340 $ obj = new Obj1 ('Hello ' ,0 ,true ,null ,'he ' );
13411341 $ j ->addArray ('array ' ,["my-obj " => $ obj ,"empty-arr " => []],true );
13421342 $ this ->assertEquals ('{ ' ."\r\n"
@@ -1364,7 +1364,7 @@ public function testFormat15() {
13641364 'bool ' => true ,
13651365 'number ' => 667 ,
13661366 'jsonx ' => new Json (['sub-json-x ' => new Json ()])
1367- ],true );
1367+ ],null , null , true );
13681368 $ this ->assertEquals (''
13691369 .'{ ' ."\r\n"
13701370 .' "hello":"world", ' ."\r\n"
@@ -1390,7 +1390,7 @@ public function testFormat15() {
13901390 * @test
13911391 */
13921392 public function testFormat16 () {
1393- $ j = new Json ([],true );
1393+ $ j = new Json ([], null , null , true );
13941394 $ j ->addArray ('hello-arr ' ,[new Json (),new Json (['hello ' => "world " ])]);
13951395 $ this ->assertEquals ("{ \r\n"
13961396 .' "hello-arr":[ ' ."\r\n"
@@ -1406,7 +1406,7 @@ public function testFormat16() {
14061406 * @test
14071407 */
14081408 public function testFormat17 () {
1409- $ j = new Json ([],true );
1409+ $ j = new Json ([], null , null , true );
14101410 $ j ->addArray ('Hello_arr ' ,["my-j " => new Json (),new Json (['Hello_x ' => "world " ])],true );
14111411 $ this ->assertEquals ("{ \r\n"
14121412 .' "Hello_arr":{ ' ."\r\n"
@@ -1421,6 +1421,41 @@ public function testFormat17() {
14211421 $ j ->setPropsStyle ('kebab ' );
14221422 $ this ->assertEquals (['hello-arr ' ],$ j ->getPropsNames ());
14231423 }
1424+ /**
1425+ * @test
1426+ */
1427+ public function testFormat18 () {
1428+ $ j = new Json ([
1429+ "hello " => "world " ,
1430+ 'object ' => new Obj0 ('8 ' ,7 ,'6 ' ,'5 ' ,4 ),
1431+ 'null ' => null ,
1432+ 'nan ' => NAN ,
1433+ 'inf ' => INF ,
1434+ 'bool ' => true ,
1435+ 'number ' => 667 ,
1436+ 'jsonx ' => new Json (['sub-json-x ' => new Json ()])
1437+ ],null ,'upper ' ,true );
1438+ $ this ->assertEquals (''
1439+ .'{ ' ."\r\n"
1440+ .' "HELLO":"world", ' ."\r\n"
1441+ .' "OBJECT":{ ' ."\r\n"
1442+ .' "PROPERTY00":"8", ' ."\r\n"
1443+ .' "PROPERTY01":7, ' ."\r\n"
1444+ .' "PROPERTY02":"6", ' ."\r\n"
1445+ .' "PROPERTY04":4 ' ."\r\n"
1446+ .' }, ' ."\r\n"
1447+ .' "NULL":null, ' ."\r\n"
1448+ .' "NAN":"NaN", ' ."\r\n"
1449+ .' "INF":"Infinity", ' ."\r\n"
1450+ .' "BOOL":true, ' ."\r\n"
1451+ .' "NUMBER":667, ' ."\r\n"
1452+ .' "JSONX":{ ' ."\r\n"
1453+ .' "SUB-JSON-X":{ ' ."\r\n"
1454+ .' } ' ."\r\n"
1455+ .' } ' ."\r\n"
1456+ .'} '
1457+ .'' ,$ j .'' );
1458+ }
14241459 /**
14251460 * @test
14261461 */
@@ -1573,7 +1608,7 @@ public function testPropCase02() {
15731608 * @test
15741609 */
15751610 public function testStyle () {
1576- define ('JSON_PROP_STYLE ' ,'snake ' );
1611+ define ('JSON_STYLE ' ,'snake ' );
15771612 $ json = new Json ();
15781613 $ this ->assertEquals ('snake ' ,$ json ->getPropStyle ());
15791614 }
0 commit comments