From da2c8923328a3f852331fca5778214e05d8e6fde Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 1 Mar 2017 09:14:04 -0600 Subject: [PATCH] formatting --- .../Foundation/Testing/TestResponse.php | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/Illuminate/Foundation/Testing/TestResponse.php b/src/Illuminate/Foundation/Testing/TestResponse.php index 5df7f8effff9..1db72d501c58 100644 --- a/src/Illuminate/Foundation/Testing/TestResponse.php +++ b/src/Illuminate/Foundation/Testing/TestResponse.php @@ -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; } /**