diff --git a/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php b/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php index b9824d815e7b..6ead7bd3e5eb 100644 --- a/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php +++ b/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php @@ -7,6 +7,7 @@ use Illuminate\Http\Request; use Illuminate\Contracts\View\View; use PHPUnit_Framework_Assert as PHPUnit; +use PHPUnit_Framework_ExpectationFailedException; use Symfony\Component\HttpFoundation\File\UploadedFile as SymfonyUploadedFile; trait MakesHttpRequests @@ -252,7 +253,13 @@ public function seeJson(array $data = null, $negate = false) return $this; } - return $this->seeJsonContains($data, $negate); + try { + $this->seeJsonEquals($data); + + return $this; + } catch(PHPUnit_Framework_ExpectationFailedException $e) { + return $this->seeJsonContains($data, $negate); + } } /** diff --git a/tests/Foundation/FoundationCrawlerTraitJsonTest.php b/tests/Foundation/FoundationCrawlerTraitJsonTest.php index a6670277269d..5fe8d6ab7dc9 100644 --- a/tests/Foundation/FoundationCrawlerTraitJsonTest.php +++ b/tests/Foundation/FoundationCrawlerTraitJsonTest.php @@ -2,10 +2,28 @@ use Illuminate\Foundation\Testing\Concerns\MakesHttpRequests; -class FoundationCrawlerTraitJsonTest extends PHPUnit_Framework_TestCase +class FoundationMakesHttpRequestsJsonTest extends PHPUnit_Framework_TestCase { use MakesHttpRequests; + public function testSeeJsonWithArray() + { + $this->response = new Illuminate\Http\Response(new JsonSerializableSingleResourceStub); + + $resource = new JsonSerializableSingleResourceStub; + + $this->seeJson($resource->jsonSerialize()); + } + + public function testSeeJsonWithMixed() + { + $this->response = new Illuminate\Http\Response(new JsonSerializableMixedResourcesStub); + + $resource = new JsonSerializableMixedResourcesStub; + + $this->seeJson($resource->jsonSerialize()); + } + public function testSeeJsonStructure() { $this->response = new Illuminate\Http\Response(new JsonSerializableMixedResourcesStub);