diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 2885355..672056d 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -16,7 +16,7 @@ jobs: strategy: matrix: - php_version: ['8.1', '8.2'] + php_version: ['8.1', '8.2', '8.3'] steps: - uses: actions/checkout@v3 diff --git a/composer.json b/composer.json index 06cec5a..04ceb2f 100644 --- a/composer.json +++ b/composer.json @@ -11,13 +11,13 @@ "type": "library", "require": { "php": "^8.1", - "illuminate/collections": "^8.0|^9.0|^10.0", - "illuminate/http": "^8.0|^9.0|^10.0", - "illuminate/support": "^8.0|^9.0|^10.0" + "illuminate/collections": "^9.0|^10.0|^11.0", + "illuminate/http": "^9.0|^10.0|^11.0", + "illuminate/support": "^9.0|^10.0|^11.0" }, "require-dev": { "phpunit/phpunit": "^9.5|^10.0", - "orchestra/testbench": "^7.0|^8.0", + "orchestra/testbench": "^7.0|^8.0|^9.0|^10.0", "phpstan/phpstan": "^1.9.18" }, "license": "MIT", diff --git a/phpstan.neon b/phpstan.neon index 63d987b..81d4598 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -6,4 +6,7 @@ parameters: - tests/app/migrations.php - tests/app/routes.php level: 6 - checkGenericClassInNonGenericObjectType: false + + ignoreErrors: + - + identifier: missingType.generics diff --git a/phpunit.php8.1.xml.dist b/phpunit.php8.1.xml.dist index 2cd5a05..8ef7a48 100644 --- a/phpunit.php8.1.xml.dist +++ b/phpunit.php8.1.xml.dist @@ -1,25 +1,26 @@ - - - tests/Unit - - - tests/Feature - - - - - src - - - - - - + failOnWarning="true" +> + + + tests/Unit + + + tests/Feature + + + + + + + + + src + + diff --git a/phpunit.php8.2.xml.dist b/phpunit.php8.2.xml.dist index 2cd5a05..8ef7a48 100644 --- a/phpunit.php8.2.xml.dist +++ b/phpunit.php8.2.xml.dist @@ -1,25 +1,26 @@ - - - tests/Unit - - - tests/Feature - - - - - src - - - - - - + failOnWarning="true" +> + + + tests/Unit + + + tests/Feature + + + + + + + + + src + + diff --git a/phpunit.php8.3.xml.dist b/phpunit.php8.3.xml.dist new file mode 100644 index 0000000..8ef7a48 --- /dev/null +++ b/phpunit.php8.3.xml.dist @@ -0,0 +1,26 @@ + + + + + tests/Unit + + + tests/Feature + + + + + + + + + src + + + diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 2cd5a05..8ef7a48 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,25 +1,26 @@ - - - tests/Unit - - - tests/Feature - - - - - src - - - - - - + failOnWarning="true" +> + + + tests/Unit + + + tests/Feature + + + + + + + + + src + + diff --git a/src/Resources/Relationship.php b/src/Resources/Relationship.php index 0a19af0..6083e38 100644 --- a/src/Resources/Relationship.php +++ b/src/Resources/Relationship.php @@ -144,9 +144,9 @@ public function forRelation(string $relation): self public function toArray(mixed $request, bool $included = true): array { $value = $this->whenIncluded && !$included - ? new MissingValue - : value($this->value) - ?? new MissingValue; + ? null + : value($this->value); + $value ??= new MissingValue; if ($this->asCollection && !is_subclass_of($this->resource, ResourceCollection::class)) { $resource = $this->resource::collection($value); diff --git a/tests/Feature/FeatureTestCase.php b/tests/Feature/FeatureTestCase.php index c0195da..9ca6365 100644 --- a/tests/Feature/FeatureTestCase.php +++ b/tests/Feature/FeatureTestCase.php @@ -23,10 +23,13 @@ protected function defineRoutes($router) include __DIR__ . '/../app/routes.php'; } - protected function afterRefreshingDatabase() + protected function beforeRefreshingDatabase() { $this->loadMigrationsFrom(__DIR__ . '/../app/migrations.php'); + } + protected function afterRefreshingDatabase() + { self::loadSeed(); } diff --git a/tests/Feature/User/ResourceTest.php b/tests/Feature/User/ResourceTest.php index 15d8951..20c67c3 100644 --- a/tests/Feature/User/ResourceTest.php +++ b/tests/Feature/User/ResourceTest.php @@ -126,11 +126,11 @@ public function testShowMultipleFailures() $response->assertUnprocessable(); $response->assertJsonValidationErrors(['include' => [ 'The selected include is invalid.', - '"posts" doesn\'t have relationship "one"', - '"user" doesn\'t have relationship "two"', + '"posts" doesn\'t have relationship "one".', + '"user" doesn\'t have relationship "two".', ], 'fields' => [ 'The selected fields is invalid.', - '"user" doesn\'t have relationship "one_field"', + '"user" doesn\'t have fields "one_field".', '"unknown" doesn\'t exists.', ]]); } diff --git a/tests/Unit/Support/ValuesTest.php b/tests/Unit/Support/ValuesTest.php index 8465688..4189c7c 100644 --- a/tests/Unit/Support/ValuesTest.php +++ b/tests/Unit/Support/ValuesTest.php @@ -111,7 +111,7 @@ public function isMissing() /** * Return a list of data to test hasAttribute method */ - public function dataAttribute() + public static function dataAttribute() { return [ 'array' => [['a' => 1], 'a', true, 1],