Skip to content

[13.x] Fix assertJsonMissingPath() ignoring wildcards - #61441

Merged
taylorotwell merged 3 commits into
laravel:13.xfrom
xurshudyan:json-missing-path-wildcards
Sep 6, 2026
Merged

taylorotwell merged 3 commits into
laravel:13.xfrom
xurshudyan:json-missing-path-wildcards

Conversation

@xurshudyan

Copy link
Copy Markdown
Contributor

assertJsonPath() supports wildcards, since it resolves the path with data_get(). assertJsonMissingPath() uses Arr::has(), which doesn't, so it treats the * as a literal key name, the lookup fails at that segment, and the assertion passes no matter what the response holds:

// {"data": [{"id": 1, "token": "..."}, {"id": 2, "token": "..."}]}

$response->assertJsonPath('data.*.id', [1, 2]);   // passes, wildcard resolved
$response->assertJsonMissingPath('data.*.token'); // also passes, token is right there

@xurshudyan
xurshudyan marked this pull request as draft September 4, 2026 15:52
@xurshudyan
xurshudyan marked this pull request as ready for review September 4, 2026 16:04
@taylorotwell
taylorotwell merged commit 911778b into laravel:13.x Sep 6, 2026
54 checks passed
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