@@ -299,10 +299,12 @@ public function testAssertCookieExpired()
299299
300300 public function testGetJSON ()
301301 {
302- $ this ->getTestResponse (['foo ' => 'bar ' ]);
303- $ formatter = Services::format ()->getFormatter ('application/json ' );
302+ $ data = ['foo ' => 'bar ' ];
303+ $ this ->getTestResponse ('' );
304+ $ this ->response ->setJSON ($ data , true );
304305
305- $ this ->assertSame ($ formatter ->format (['foo ' => 'bar ' ]), $ this ->testResponse ->getJSON ());
306+ $ formatter = Services::format ()->getFormatter ('application/json ' );
307+ $ this ->assertSame ($ formatter ->format ($ data ), $ this ->testResponse ->getJSON ());
306308 }
307309
308310 public function testGetJSONEmptyJSON ()
@@ -344,30 +346,36 @@ public function testGetJSONInvalidJSON()
344346
345347 public function testGetXML ()
346348 {
347- $ this ->getTestResponse (['foo ' => 'bar ' ]);
348- $ formatter = Services::format ()->getFormatter ('application/xml ' );
349+ $ data = ['foo ' => 'bar ' ];
350+ $ this ->getTestResponse ('' );
351+ $ this ->response ->setXML ($ data );
349352
350- $ this ->assertSame ($ formatter ->format (['foo ' => 'bar ' ]), $ this ->testResponse ->getXML ());
353+ $ formatter = Services::format ()->getFormatter ('application/xml ' );
354+ $ this ->assertSame ($ formatter ->format ($ data ), $ this ->testResponse ->getXML ());
351355 }
352356
353357 public function testAssertJSONFragment ()
354358 {
355- $ this -> getTestResponse ( [
359+ $ data = [
356360 'config ' => [
357361 'key-a ' ,
358362 'key-b ' ,
359363 ],
360- ]);
364+ ];
365+ $ this ->getTestResponse ('' );
366+ $ this ->response ->setJSON ($ data , true );
361367
362368 $ this ->testResponse ->assertJSONFragment (['config ' => ['key-a ' ]]);
363369 $ this ->testResponse ->assertJSONFragment (['config ' => ['key-a ' ]], true );
364370 }
365371
366372 public function testAssertJSONFragmentFollowingAssertArraySubset ()
367373 {
368- $ this -> getTestResponse ( [
374+ $ data = [
369375 'config ' => '124 ' ,
370- ]);
376+ ];
377+ $ this ->getTestResponse ('' );
378+ $ this ->response ->setJSON ($ data , true );
371379
372380 $ this ->testResponse ->assertJSONFragment (['config ' => 124 ]); // must fail on strict
373381 $ this ->testResponse ->assertJSONFragment (['config ' => '124 ' ], true );
@@ -391,8 +399,8 @@ public function testAssertJsonExactArray()
391399 'key-b ' ,
392400 ],
393401 ];
394-
395- $ this ->getTestResponse ($ data );
402+ $ this -> getTestResponse ( '' );
403+ $ this ->response -> setJSON ($ data, true );
396404
397405 $ this ->testResponse ->assertJSONExact ($ data );
398406 }
@@ -405,10 +413,10 @@ public function testAssertJsonExactString()
405413 'key-b ' ,
406414 ],
407415 ];
416+ $ this ->getTestResponse ('' );
417+ $ this ->response ->setJSON ($ data , true );
408418
409- $ this ->getTestResponse ($ data );
410419 $ formatter = Services::format ()->getFormatter ('application/json ' );
411-
412420 $ this ->testResponse ->assertJSONExact ($ formatter ->format ($ data ));
413421 }
414422
0 commit comments