Skip to content

Commit

Permalink
Merge branch 'Add-context-to-assert-json' of https://github.com/nisaa…
Browse files Browse the repository at this point in the history
…c2fly/framework into nisaac2fly-Add-context-to-assert-json
  • Loading branch information
taylorotwell committed Mar 1, 2017
2 parents e09b9eb + 7b9f35b commit daadf13
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Illuminate/Foundation/Testing/TestResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,16 @@ public function assertDontSee($value)
*/
public function assertJson(array $data)
{
PHPUnit::assertArraySubset($data, $this->decodeResponseJson());
$options = JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES;
$expected = json_encode($data, $options);
$actual = json_encode($this->decodeResponseJson(), $options);

$message = 'Unable to find JSON subset: '.PHP_EOL.PHP_EOL.
"[{$expected}]".PHP_EOL.PHP_EOL.
'within'.PHP_EOL.PHP_EOL.
"[{$actual}].".PHP_EOL.PHP_EOL;

PHPUnit::assertArraySubset($data, $this->decodeResponseJson(), $strict = false, $message);

return $this;
}
Expand Down

0 comments on commit daadf13

Please sign in to comment.