@@ -834,6 +834,40 @@ public function testGetJson()
834834 $ this ->assertEquals ('{"size":41,"color":"black","meta":{"code":65076}} ' , $ jsonObject ->getJson ());
835835 }
836836
837+ public function testGetJsonWithoutOptionsBitmask ()
838+ {
839+ $ jsonObject = new JsonObject ();
840+ $ jsonObject
841+ ->add ('$ ' , 'Ö Kent C. Dodds ' , 'author ' )
842+ ->add ('$ ' , 'À First Timers Only ' , 'title ' )
843+ ->add ('$ ' , array (), 'volunteers ' )
844+ ->add ('$.volunteers[0] ' , 'Fayçal ' , 'name ' );
845+ $ expectedJson = '{"author":"\u00d6 Kent C. Dodds","title":"\u00c0 First Timers Only","volunteers":[{"name":"Fay\u00e7al"}]} ' ;
846+ $ this ->assertEquals ($ expectedJson , $ jsonObject ->getJson ());
847+ }
848+
849+ public function testGetJsonWithOptionsBitmask ()
850+ {
851+ $ jsonObject = new JsonObject ();
852+ $ jsonObject
853+ ->add ('$ ' , 'Ö Kent C. Dodds ' , 'author ' )
854+ ->add ('$ ' , 'À First Timers Only ' , 'title ' )
855+ ->add ('$ ' , array (), 'volunteers ' )
856+ ->add ('$.volunteers[0] ' , 'Fayçal ' , 'name ' );
857+ $ expectedJson = <<<EOF
858+ {
859+ "author": "Ö Kent C. Dodds",
860+ "title": "À First Timers Only",
861+ "volunteers": [
862+ {
863+ "name": "Fayçal"
864+ }
865+ ]
866+ }
867+ EOF ;
868+ $ this ->assertEquals ($ expectedJson , $ jsonObject ->getJson (JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT ));
869+ }
870+
837871 public function testMagickMethods ()
838872 {
839873 $ jsonObject = new JsonObject ($ this ->json );
0 commit comments