-
-
Notifications
You must be signed in to change notification settings - Fork 403
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix having
null
as the filter query parameter name
- Loading branch information
1 parent
d000feb
commit b416e5a
Showing
3 changed files
with
42 additions
and
13 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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
use Spatie\QueryBuilder\QueryBuilder; | ||
use Spatie\QueryBuilder\Tests\TestClasses\Models\TestModel; | ||
|
||
it('can instantiate the query builder and filter the query for an actual api request', function () { | ||
TestModel::factory()->create(); | ||
|
||
config(['query-builder.parameters.filter' => null]); | ||
|
||
Route::get('/test-request', function () { | ||
return QueryBuilder::for(TestModel::class) | ||
->allowedIncludes(['group', 'incidents']) | ||
->allowedFilters(['name', 'status', 'enabled']) | ||
->allowedSorts(['name', 'order', 'id']) | ||
->simplePaginate(request('per_page', 15)); | ||
}); | ||
|
||
$response = $this->getJson('/test-request'); | ||
|
||
$response->assertOk(); | ||
$response->assertJsonCount(1, 'data'); | ||
}); |
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