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

[9.x] Add new TestResponse helper: assertJsonMissingPath #42361

Merged
merged 2 commits into from
May 12, 2022

Conversation

danilopolani
Copy link
Contributor

This PR adds a new assertJsonMissingPath() HTTP Testing helper.
It's very useful to check that a path does dot exist, regardless of its content, especially for deep nested data.

$this->getJson('/users/1')
    ->assertOk()
    ->assertJsonMissingPath('email'); // Never return the user email

$this->getJson('/articles')
    ->assertOk()
    ->assertJsonMissingPath('data.0.internalTags');

Currently the only similar option is to use assertJsonMissing but you have to create the whole nested structure and know the data that should be inside and could be a pain sometimes, for example if wanting to check that an array does not exist and you don't know the order of its items.

@taylorotwell taylorotwell merged commit c894325 into laravel:9.x May 12, 2022
@danilopolani danilopolani deleted the feat/assert-json-missing-path branch May 12, 2022 15:26
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.

2 participants