Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.2] Fix bug in seeJson failing when comparing two equal arrays #13531

Merged
merged 1 commit into from
May 15, 2016
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