generated from spatie/package-skeleton-laravel
-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from edalzell/fix/get-query-params
Support query params on GET requests
- Loading branch information
Showing
2 changed files
with
18 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -233,7 +233,7 @@ | |
}); | ||
|
||
it('can add query parameters', function () { | ||
$response = TestRequest::fake()->setPath( | ||
$request = TestRequest::fake()->setPath( | ||
path: '/comments', | ||
)->withQuery( | ||
query: [ | ||
|
@@ -261,7 +261,9 @@ | |
'email' => '[email protected]', | ||
'body' => "quia molestiae reprehenderit quasi aspernatur\naut expedita occaecati aliquam eveniet laudantium\nomnis quibusdam delectus saepe quia accusamus maiores nam est\ncum et ducimus et vero voluptates excepturi deleniti ratione", | ||
], | ||
])->send(); | ||
]); | ||
|
||
$response = $request->send(); | ||
|
||
expect( | ||
$response->json() | ||
|
@@ -270,6 +272,8 @@ | |
foreach ($response->json() as $item) { | ||
expect($item['postId'])->toBe(1); | ||
} | ||
|
||
expect($request->getUrl())->toBe('/comments?postId=1'); | ||
}); | ||
|
||
it('can add data to the request', function () { | ||
|
@@ -370,7 +374,7 @@ | |
}); | ||
|
||
it('can add query parameters recursively without overwriting', function () { | ||
$query = TestRequest::fake() | ||
$request = TestRequest::fake() | ||
->withQuery( | ||
query: [ | ||
'postId' => 1, | ||
|
@@ -387,7 +391,9 @@ | |
'size' => 30, | ||
], | ||
], | ||
)->getQuery(); | ||
); | ||
|
||
$query = $request->getQuery(); | ||
|
||
expect( | ||
$query | ||
|
@@ -404,6 +410,8 @@ | |
expect( | ||
$query['page']['size'] | ||
)->toBe(30); | ||
|
||
expect($request->getUrl())->toBe('/todos?postId=1&page%5Bnumber%5D=2&page%5Bsize%5D=30'); | ||
}); | ||
|
||
it('can get the request payload', function () { | ||
|