From fe28a8bd78d8de2ec9d9e1b6834a3b1286d1466a Mon Sep 17 00:00:00 2001 From: Reinand Date: Fri, 6 Feb 2026 12:34:23 +0100 Subject: [PATCH 1/5] Add matrix strategy to test job --- .github/workflows/test.yml | 42 +++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 016ba68..46e520e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,17 +10,45 @@ jobs: test: runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: [8.2, 8.3, 8.4] + laravel: [10.*, 11.*, 12.*] + include: + - laravel: 10.* + testbench: ^8.0 + phpunit: ^10.0 + - laravel: 11.* + testbench: ^9.0 + phpunit: ^10.5 + - laravel: 12.* + testbench: ^10.0 + phpunit: ^11.0 + exclude: + # Laravel 10 doesn't support PHP 8.4 + - php: 8.4 + laravel: 10.* + + name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} + steps: - uses: actions/checkout@v3 - - uses: php-actions/composer@v6 - - - name: PHPUnit Tests - uses: php-actions/phpunit@master + - name: Setup PHP + uses: shivammathur/setup-php@v2 with: - version: 9.6 - bootstrap: vendor/autoload.php - configuration: ./phpunit.xml + php-version: ${{ matrix.php }} + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv + coverage: none + + - name: Install dependencies + run: | + composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "phpunit/phpunit:${{ matrix.phpunit }}" --no-interaction --no-update + composer update --prefer-dist --no-interaction --no-progress + + - name: Execute tests + run: vendor/bin/phpunit lint: runs-on: ubuntu-latest From baccef619782ceb7c8de399d81128a1f4811a497 Mon Sep 17 00:00:00 2001 From: Reinand Date: Fri, 6 Feb 2026 14:10:41 +0100 Subject: [PATCH 2/5] Add php 8.5 support to matrix --- .github/workflows/test.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 46e520e..d8d6ac6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - php: [8.2, 8.3, 8.4] + php: [8.2, 8.3, 8.4, 8.5] laravel: [10.*, 11.*, 12.*] include: - laravel: 10.* @@ -29,6 +29,11 @@ jobs: # Laravel 10 doesn't support PHP 8.4 - php: 8.4 laravel: 10.* + # Only Laravel 12 supports PHP 8.5 + - php: 8.5 + laravel: 10.* + - php: 8.5 + laravel: 11.* name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} @@ -44,7 +49,8 @@ jobs: - name: Install dependencies run: | - composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "phpunit/phpunit:${{ matrix.phpunit }}" --no-interaction --no-update + composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update + composer require "orchestra/testbench:${{ matrix.testbench }}" "phpunit/phpunit:${{ matrix.phpunit }}" --dev --no-interaction --no-update composer update --prefer-dist --no-interaction --no-progress - name: Execute tests From f26db6e655ff67c7b309a8aaef6adc183bbdb7fa Mon Sep 17 00:00:00 2001 From: Reinand Date: Fri, 6 Feb 2026 14:11:19 +0100 Subject: [PATCH 3/5] Change access level on `JsonApiResource::toAttributes()` to public --- src/Resources/JsonApiResource.php | 2 +- tests/Resources/DeveloperResource.php | 2 +- tests/Resources/InternResource.php | 2 +- tests/Resources/PullRequestResource.php | 2 +- tests/Resources/ReviewResource.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Resources/JsonApiResource.php b/src/Resources/JsonApiResource.php index 09cf1a9..e3dd4f1 100644 --- a/src/Resources/JsonApiResource.php +++ b/src/Resources/JsonApiResource.php @@ -172,7 +172,7 @@ protected function getType(): string * Default to either `registerData['attributes']` or an empty array. * Should be overwritten to create custom attributes. */ - protected function toAttributes(Request $request): array + public function toAttributes(Request $request): array { return $this->registerData['attributes'] ?? []; } diff --git a/tests/Resources/DeveloperResource.php b/tests/Resources/DeveloperResource.php index 0235428..315161b 100644 --- a/tests/Resources/DeveloperResource.php +++ b/tests/Resources/DeveloperResource.php @@ -9,7 +9,7 @@ class DeveloperResource extends JsonApiResource { protected string $type = 'developers'; - protected function toAttributes(Request $request): array + public function toAttributes(Request $request): array { return [ 'name' => $this->resource->name, diff --git a/tests/Resources/InternResource.php b/tests/Resources/InternResource.php index ad47170..a18b1f0 100644 --- a/tests/Resources/InternResource.php +++ b/tests/Resources/InternResource.php @@ -13,7 +13,7 @@ class InternResource extends JsonApiResource { protected string $type = 'interns'; - protected function toAttributes(Request $request): array + public function toAttributes(Request $request): array { return [ 'name' => $this->resource->name, diff --git a/tests/Resources/PullRequestResource.php b/tests/Resources/PullRequestResource.php index 433b1d1..945b303 100644 --- a/tests/Resources/PullRequestResource.php +++ b/tests/Resources/PullRequestResource.php @@ -9,7 +9,7 @@ class PullRequestResource extends JsonApiResource { protected string $type = 'pull_requests'; - protected function toAttributes(Request $request): array + public function toAttributes(Request $request): array { return [ 'title' => $this->resource->title, diff --git a/tests/Resources/ReviewResource.php b/tests/Resources/ReviewResource.php index 7aff566..a8515d2 100644 --- a/tests/Resources/ReviewResource.php +++ b/tests/Resources/ReviewResource.php @@ -9,7 +9,7 @@ class ReviewResource extends JsonApiResource { protected string $type = 'reviews'; - protected function toAttributes(Request $request): array + public function toAttributes(Request $request): array { return [ 'content' => $this->resource->content, From 6b8634d820bdcba8b3b65dbe08a8e0b4de629261 Mon Sep 17 00:00:00 2001 From: Reinand Date: Fri, 6 Feb 2026 14:17:20 +0100 Subject: [PATCH 4/5] Add `resolveResourceData` override --- src/Resources/JsonApiResource.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Resources/JsonApiResource.php b/src/Resources/JsonApiResource.php index e3dd4f1..e9d4b62 100644 --- a/src/Resources/JsonApiResource.php +++ b/src/Resources/JsonApiResource.php @@ -75,6 +75,13 @@ public function toArray($request): array : $this->addToResponse($request, $this->getResourceData($request)); } + public function resolveResourceData($request): array + { + return is_null($this->resource) + ? [] + : $this->addToResponse($request, $this->getResourceData($request)); + } + /** * Returns the value of $this->data and sets it if it's empty. */ From fd37e643999db4bce963c689ab25c13ec8be4e8a Mon Sep 17 00:00:00 2001 From: Reinand Date: Fri, 6 Feb 2026 15:03:40 +0100 Subject: [PATCH 5/5] Add docblock to `resolveResourceData` override --- src/Resources/JsonApiResource.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Resources/JsonApiResource.php b/src/Resources/JsonApiResource.php index e9d4b62..1956e8c 100644 --- a/src/Resources/JsonApiResource.php +++ b/src/Resources/JsonApiResource.php @@ -75,6 +75,12 @@ public function toArray($request): array : $this->addToResponse($request, $this->getResourceData($request)); } + /** + * Resolve the resource data to an array. + * + * Override Laravel 12's implementation to prevent circular dependency + * between toArray() and toAttributes(). + */ public function resolveResourceData($request): array { return is_null($this->resource)