diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 724cdca..ae0cb51 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -17,9 +17,9 @@ jobs: strategy: fail-fast: true matrix: - php: [8.2, 8.3, 8.4, 8.5] - laravel: [11, 12, 13] - phpunit: ['10.5', '11.0'] + php: [8.2, 8.3, 8.4, 8.5, 8.6] + laravel: [12, 13] + phpunit: ['11.0'] exclude: - laravel: '13' php: 8.2 diff --git a/CHANGELOG.md b/CHANGELOG.md index bd95a04..b23d35c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. This projec ## Unreleased +### Changed + +- Dropped Laravel 11, as it is end of life and not receiving security updates. + ## [3.2.0] - 2026-03-28 ### Added diff --git a/composer.json b/composer.json index add044c..b0abfdd 100644 --- a/composer.json +++ b/composer.json @@ -26,13 +26,13 @@ "php": "^8.2", "ext-json": "*", "cloudcreativity/json-api-testing": "^6.3", - "illuminate/http": "^11.0|^12.0|^13.0", - "illuminate/support": "^11.0|^12.0|^13.0", - "illuminate/testing": "^11.0|^12.0|^13.0" + "illuminate/http": "^12.0|^13.0", + "illuminate/support": "^12.0|^13.0", + "illuminate/testing": "^12.0|^13.0" }, "require-dev": { - "laravel/framework": "^11.0|^12.0|^13.0", - "phpunit/phpunit": "^10.5|^11.0" + "laravel/framework": "^12.71|^13.2", + "phpunit/phpunit": "^11.5" }, "autoload": { "psr-4": { diff --git a/src/TestBuilder.php b/src/TestBuilder.php index 04583d9..24875b6 100644 --- a/src/TestBuilder.php +++ b/src/TestBuilder.php @@ -366,13 +366,13 @@ public function call(string $method, string $uri, iterable $headers = []): TestR $headers = $this->buildHeaders($headers); if ($this->payload) { - $payload = $this->payload->toArray(); // we need a content length as it is used by the JSON API implementation to determine if there is body. - $headers['CONTENT_LENGTH'] = $headers['CONTENT_LENGTH'] ?? mb_strlen(Arr::query($payload), '8bit'); + $headers['CONTENT_LENGTH'] = $headers['CONTENT_LENGTH'] ?? + mb_strlen(Arr::query($this->buildPayloadForContentLength()), '8bit'); $response = $this->test->{strtolower($method)}( $uri, - $payload, + $this->payload->toArray(), $headers ); } else { @@ -417,6 +417,19 @@ private function buildQuery(): string return Arr::query($query); } + private function buildPayloadForContentLength(): array + { + $payload = $this->payload->toArray(); + + array_walk_recursive($payload, function (&$value) { + if (is_object($value)) { + $value = get_object_vars($value); + } + }); + + return $payload; + } + /** * @param iterable $headers * @return array diff --git a/tests/Unit/TestBuilderTest.php b/tests/Unit/TestBuilderTest.php index ef875bb..7b34843 100644 --- a/tests/Unit/TestBuilderTest.php +++ b/tests/Unit/TestBuilderTest.php @@ -14,6 +14,7 @@ use Illuminate\Contracts\Routing\UrlRoutable; use Illuminate\Foundation\Testing\Concerns\MakesHttpRequests; use Illuminate\Http\Response; +use Illuminate\Http\UploadedFile; use Illuminate\Support\Arr; use Illuminate\Support\Collection; use Illuminate\Support\Str; @@ -361,12 +362,22 @@ public function testWithJson(): void public function testWithPayload(): void { - $payload = ['foo' => 'bar', 'baz' => 'bat']; + $payload = [ + 'foo' => 'bar', + 'baz' => 'bat', + 'file' => $file = UploadedFile::fake()->image('avatar.jpg'), + ]; + + $parsed = [ + 'foo' => 'bar', + 'baz' => 'bat', + 'file' => get_object_vars($file), + ]; $headers = [ 'Accept' => 'application/vnd.api+json', 'CONTENT_TYPE' => 'application/x-www-form-urlencoded', - 'CONTENT_LENGTH' => mb_strlen(Arr::query($payload), '8bit'), + 'CONTENT_LENGTH' => mb_strlen(Arr::query($parsed), '8bit'), ]; $this->mock