Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
}

/**
Expand Down
20 changes: 19 additions & 1 deletion tests/Foundation/FoundationCrawlerTraitJsonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down