Skip to content

Commit

Permalink
Fix bug in seeJson failing when comparing two equal arrays (#13531)
Browse files Browse the repository at this point in the history
  • Loading branch information
sileence authored and taylorotwell committed May 15, 2016
1 parent 43aa875 commit b099fd3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
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

0 comments on commit b099fd3

Please sign in to comment.