Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Mar 1, 2017
1 parent daadf13 commit da2c892
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions src/Illuminate/Foundation/Testing/TestResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,18 +201,29 @@ public function assertDontSee($value)
*/
public function assertJson(array $data)
{
$options = JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES;
$expected = json_encode($data, $options);
$actual = json_encode($this->decodeResponseJson(), $options);
PHPUnit::assertArraySubset(
$data, $this->decodeResponseJson(), false, $this->assertJsonMessage($data)
);

$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;
return $this;
}

/**
* Get the assertion message for assertJson.
*
* @param array $data
* @return string
*/
protected function assertJsonMessage(array $data)
{
$expected = json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);

PHPUnit::assertArraySubset($data, $this->decodeResponseJson(), $strict = false, $message);
$actual = json_encode($this->decodeResponseJson(), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);

return $this;
return 'Unable to find JSON: '.PHP_EOL.PHP_EOL.
"[{$expected}]".PHP_EOL.PHP_EOL.
'within response JSON:'.PHP_EOL.PHP_EOL.
"[{$actual}].".PHP_EOL.PHP_EOL;
}

/**
Expand Down

0 comments on commit da2c892

Please sign in to comment.