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

[6.x] Strict parameter added to assertJsonPath #30142

Merged
merged 1 commit into from
Oct 1, 2019
Merged

Conversation

ttrig
Copy link
Contributor

@ttrig ttrig commented Sep 30, 2019

Allows strict comparison when using assertJsonPath.

Example response data:

{
    "foo": false
}

The problem

$response->assertJsonPath('foo', 0); // pass
$response->assertJsonPath('foo', null); // pass

The solution

$response->assertJsonPath('foo', 0, true); // fail
$response->assertJsonPath('foo', null, true); // fail
$response->assertJsonPath('foo', false, true); // pass

@driesvints driesvints changed the title Strict parameter added to assertJsonPath [6.x] Strict parameter added to assertJsonPath Sep 30, 2019
@BrandonSurowiec
Copy link
Contributor

BrandonSurowiec commented Sep 30, 2019

Can we add an additional assertJsonPathStrict() method?

public function assertJsonPathStrict($path, $expect)
{
    return $this->assertJsonPath($path, $expect, true);
}

@ttrig
Copy link
Contributor Author

ttrig commented Oct 1, 2019

Can we add an additional assertJsonPathStrict() method?

public function assertJsonPathStrict($path, $expect)
{
    return $this->assertJsonPath($path, $expect, true);
}

Sure, great suggestion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants