Skip to content

[13.x] Add query and queryJson HTTP testing helpers#60662

Open
shanerbaner82 wants to merge 1 commit into
laravel:13.xfrom
shanerbaner82:add-query-http-verb
Open

[13.x] Add query and queryJson HTTP testing helpers#60662
shanerbaner82 wants to merge 1 commit into
laravel:13.xfrom
shanerbaner82:add-query-http-verb

Conversation

@shanerbaner82

Copy link
Copy Markdown

With the HTTP QUERY method gaining first-class routing support (#60655) — and Route::match(['QUERY'], ...) already working today — there is currently no fluent way to test such routes: MakesHttpRequests offers helpers for every other verb but not QUERY.

This PR adds $this->query($uri, $data, $headers) and $this->queryJson(...), mirroring the existing delete()/deleteJson() helpers since QUERY is a safe method that carries its query in the request body:

Route::match(['QUERY'], '/search', fn () => request()->input('filter'));

$this->queryJson('/search', ['filter' => 'active'])->assertOk();

Symfony HttpFoundation ≥ 7.4 (Laravel 13's minimum) natively supports QUERY in Request::create(), placing test data in the request body just like POST/PUT/DELETE — the tests assert this explicitly ($request->post('filter') is set, $request->query('filter') is not).

Fully backward compatible — purely additive, no contracts changed. Tests cover both helpers end-to-end through the router.

🤖 Generated with Claude Code

Adds query() and queryJson() methods to MakesHttpRequests so
applications can test routes responding to the HTTP QUERY method,
mirroring the existing helpers for the other HTTP verbs.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Vectorial1024

Copy link
Copy Markdown

Concept first mentioned by issue #60564, in case we want extra discussion.

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