From 065c8e7600048c2d0c3168993d99535511eb418c Mon Sep 17 00:00:00 2001 From: Mohammad Alavi Date: Sat, 21 Dec 2024 14:29:36 +0330 Subject: [PATCH] fix: wrong config usage --- config/apiato.php | 17 ----------------- tests/Unit/Services/ResponseTest.php | 7 ++++--- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/config/apiato.php b/config/apiato.php index aa24859ca..25f5e8ae1 100644 --- a/config/apiato.php +++ b/config/apiato.php @@ -150,23 +150,6 @@ // TODO: BC: remove this after removing its usage in ResponseTrait in Core 'filter' => 'fieldset', ], - - /* - |-------------------------------------------------------------------------- - | Sparse Fieldsets - |-------------------------------------------------------------------------- - | - | Sparse Fieldsets are a feature of the JSON API spec that allows clients to request only a subset of the - | attributes for a specific resource type. This can be useful for improving performance by reducing the amount - | of data that needs to be transferred over the network. - | - | @see https://jsonapi.org/format/#fetching-sparse-fieldsets - | - */ - 'sparse_fieldsets' => [ - // The name of key in the request to where we should look for the fields to return. - 'request_key' => 'fields', - ], ], 'seeders' => [ diff --git a/tests/Unit/Services/ResponseTest.php b/tests/Unit/Services/ResponseTest.php index 69775350e..d14ed8b9b 100644 --- a/tests/Unit/Services/ResponseTest.php +++ b/tests/Unit/Services/ResponseTest.php @@ -256,9 +256,9 @@ public function testPaginatedResourceMetaDataAndInclude($include): void } #[DataProvider('fieldsetDataProvider')] - public function testCanFilterResponse($fieldset, $expected, $missing): void + public function testCanFilterResponse($fields, $expected, $missing): void { - request()->merge(['include' => 'books,children.books', self::FIELDSET_KEY => $fieldset]); + request()->merge(['include' => 'books,children.books', self::FIELDSET_KEY => $fields]); $response = Response::create($this->user); $response->transformWith(UserTransformer::class); @@ -344,7 +344,8 @@ protected function setUp(): void { parent::setUp(); - config()->set('apiato.requests.sparse_fieldsets.request_key', self::FIELDSET_KEY); + config()->set('fractal.auto_fieldsets.enabled', true); + config()->set('fractal.auto_fieldsets.request_key', self::FIELDSET_KEY); $this->user = UserFactory::new() ->for(UserFactory::new()->has(BookFactory::new()), 'parent')