diff --git a/.github/workflows/code-style.yml b/.github/workflows/code-style.yml index ca851eb..e2d9761 100644 --- a/.github/workflows/code-style.yml +++ b/.github/workflows/code-style.yml @@ -20,7 +20,7 @@ jobs: - name: 🔥 Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: 8.1 + php-version: 8.3 coverage: none tools: cs2pr, pint diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index d72e35b..712fe91 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -16,19 +16,16 @@ jobs: fail-fast: true matrix: os: [ ubuntu-latest ] - php: [ 8.1, 8.2 ] - laravel: [ "^9.0", "^10.0" ] + php: [ 8.2, 8.3 ] + laravel: [ "^10.0", "^11.0" ] stability: [ prefer-lowest, prefer-stable ] include: - - laravel: "^9.0" - testbench: "^7.0" - enum: "^5.0" - - laravel: "^9.0" - testbench: "^7.0" - enum: "^6.0" - laravel: "^10.0" testbench: "^8.0" enum: "^6.0" + - laravel: "^11.0" + testbench: "^9.0" + enum: "^6.0" name: P${{ matrix.php }} - L${{ matrix.laravel }} - E${{ matrix.enum }} - ${{ matrix.stability }} - ${{ matrix.os }} diff --git a/composer.json b/composer.json index 52b2d0a..18a475f 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,7 @@ { "name": "simplesquid/nova-enum-field", "description": "A Laravel Nova field to add enums to resources.", + "license": "MIT", "keywords": [ "simplesquid", "laravel", @@ -9,8 +10,6 @@ "enum", "nova-enum-field" ], - "homepage": "https://github.com/simplesquid/nova-enum-field", - "license": "MIT", "authors": [ { "name": "Matthew Poulter", @@ -19,27 +18,30 @@ "role": "Developer" } ], - "repositories": [ - { - "type": "composer", - "url": "https://nova.laravel.com" - } - ], + "homepage": "https://github.com/simplesquid/nova-enum-field", "require": { - "php": "^8.0", + "php": "^8.1", "bensampo/laravel-enum": "^5.0 || ^6.0", - "illuminate/support": "^9.0 || ^10.0", + "illuminate/support": "^10.0 || ^11.0", "laravel/nova": "^4.0" }, "require-dev": { - "joshgaber/novaunit": "^3.1", + "ergebnis/composer-normalize": "^2.44", "laravel/pint": "^1.2", "mockery/mockery": "^1.3.3", - "nunomaduro/collision": "^6.1 || ^7.0", - "orchestra/testbench": "^7.0 || ^8.0", - "phpunit/phpunit": "^9.3.3", - "symfony/var-dumper": "^6.0" + "nunomaduro/collision": "^7.0 || ^8.0", + "orchestra/testbench": "^8.0 || ^9.0", + "phpunit/phpunit": "^10.1", + "quotevelocity/novaunit": "^4.0", + "symfony/var-dumper": "^6.0 || ^7.0" }, + "repositories": [ + { + "type": "composer", + "url": "https://nova.laravel.com" + } + ], + "minimum-stability": "stable", "autoload": { "psr-4": { "SimpleSquid\\Nova\\Fields\\Enum\\": "src" @@ -50,6 +52,12 @@ "SimpleSquid\\Nova\\Fields\\Enum\\Tests\\": "tests" } }, + "config": { + "allow-plugins": { + "ergebnis/composer-normalize": true + }, + "sort-packages": true + }, "extra": { "laravel": { "providers": [] @@ -57,9 +65,5 @@ }, "scripts": { "test": "vendor/bin/phpunit --colors=always" - }, - "config": { - "sort-packages": true - }, - "minimum-stability": "stable" + } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 2202d1a..62babd7 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,24 +1,27 @@ - - - src - - + colors="true" +> tests/Fields tests/Filters + + + + src + + + diff --git a/src/Enum.php b/src/Enum.php index 99e9fd7..88a9e6a 100644 --- a/src/Enum.php +++ b/src/Enum.php @@ -36,7 +36,7 @@ function (NovaRequest $request, $model, $attribute, $requestAttribute) { public function attach($class) { return $this->options($class::asSelectArray()) - ->rules($this->nullable ? 'nullable' : 'required', new EnumValue($class, false)); + ->rules($this->nullable ? 'nullable' : 'required', new EnumValue($class, false)); } public function nullable($nullable = true, $values = null) diff --git a/tests/Fields/FieldTest.php b/tests/Fields/FieldTest.php index cb97022..a53adff 100644 --- a/tests/Fields/FieldTest.php +++ b/tests/Fields/FieldTest.php @@ -34,7 +34,8 @@ public function it_starts_with_no_options_and_rules() /** @test */ public function it_allows_an_enum_to_be_attached() { - $this->assertObjectHasAttribute('optionsCallback', $this->field); + $this->assertIsObject($this->field); + $this->assertTrue(property_exists($this->field, 'optionsCallback')); } /** @test */ @@ -60,6 +61,6 @@ public function it_can_be_nullable() $this->assertNotContains('required', $this->field->rules); $this->assertContains('nullable', $this->field->rules); - $this->assertFalse($this->field->isRequired(new NovaRequest())); + $this->assertFalse($this->field->isRequired(new NovaRequest)); } } diff --git a/tests/Fields/FlaggedFieldTest.php b/tests/Fields/FlaggedFieldTest.php index c71ec7f..0e93ee9 100644 --- a/tests/Fields/FlaggedFieldTest.php +++ b/tests/Fields/FlaggedFieldTest.php @@ -93,7 +93,7 @@ public function it_resolves_enum_values() /** @test */ public function it_fills_database_with_flagged_enum_value() { - $request = new NovaRequest(); + $request = new NovaRequest; $request->query->add(['enum' => json_encode($this->values)]); $this->field->fill($request, $this->model); diff --git a/tests/Fields/IntegerFieldTest.php b/tests/Fields/IntegerFieldTest.php index 5455191..2f73f2a 100644 --- a/tests/Fields/IntegerFieldTest.php +++ b/tests/Fields/IntegerFieldTest.php @@ -44,7 +44,7 @@ public function it_displays_enum_description() /** @test */ public function it_fills_database_with_enum_value() { - $request = new NovaRequest(); + $request = new NovaRequest; $request->query->add(['enum' => IntegerEnum::Subscriber]); $this->field->fill($request, $this->model); diff --git a/tests/Fields/NoCastsFieldTest.php b/tests/Fields/NoCastsFieldTest.php index 80c3d0b..54a36f9 100644 --- a/tests/Fields/NoCastsFieldTest.php +++ b/tests/Fields/NoCastsFieldTest.php @@ -44,7 +44,7 @@ public function it_displays_enum_description() /** @test */ public function it_fills_database_with_enum_value() { - $request = new NovaRequest(); + $request = new NovaRequest; $request->query->add(['enum' => StringEnum::Subscriber]); $this->field->fill($request, $this->model); diff --git a/tests/Fields/StringFieldTest.php b/tests/Fields/StringFieldTest.php index 76df801..67dad02 100644 --- a/tests/Fields/StringFieldTest.php +++ b/tests/Fields/StringFieldTest.php @@ -44,7 +44,7 @@ public function it_displays_enum_description() /** @test */ public function it_fills_database_with_enum_value() { - $request = new NovaRequest(); + $request = new NovaRequest; $request->query->add(['enum' => StringEnum::Subscriber]); $this->field->fill($request, $this->model);