From ae75aa35c023c8974b8ff77f7f42d57e37f00c60 Mon Sep 17 00:00:00 2001 From: manuel Date: Thu, 30 May 2024 13:14:02 +0200 Subject: [PATCH 1/7] upgrade to Laravel 11 and PHPUnit 10 --- composer.json | 8 ++++---- phpunit.xml.dist | 38 +++++++++++++++++++------------------- tests/Fields/FieldTest.php | 3 ++- 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/composer.json b/composer.json index 52b2d0a..5e41a8c 100644 --- a/composer.json +++ b/composer.json @@ -28,16 +28,16 @@ "require": { "php": "^8.0", "bensampo/laravel-enum": "^5.0 || ^6.0", - "illuminate/support": "^9.0 || ^10.0", + "illuminate/support": "^9.0 || ^10.0 || ^11.0", "laravel/nova": "^4.0" }, "require-dev": { "joshgaber/novaunit": "^3.1", "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", + "nunomaduro/collision": "^6.1 || ^7.0 || ^8.0", + "orchestra/testbench": "^7.0 || ^8.0 || ^9.0", + "phpunit/phpunit": "^10.0", "symfony/var-dumper": "^6.0" }, "autoload": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 2202d1a..a34a972 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,24 +1,24 @@ - - - src - - - - - tests/Fields - tests/Filters - - - - - - - - - + + + tests/Fields + tests/Filters + + + + + + + + + + + + src + + diff --git a/tests/Fields/FieldTest.php b/tests/Fields/FieldTest.php index cb97022..aac2099 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 */ From 4e37972904e1e2a6d5c46a88df41f423af5e64a8 Mon Sep 17 00:00:00 2001 From: Matthew Poulter Date: Sun, 16 Jun 2024 15:30:21 +0200 Subject: [PATCH 2/7] Update workflows and remove older deps --- .github/workflows/code-style.yml | 2 +- .github/workflows/run-tests.yml | 13 ++---- composer.json | 80 ++++++++++++++++---------------- src/Enum.php | 2 +- 4 files changed, 47 insertions(+), 50 deletions(-) diff --git a/.github/workflows/code-style.yml b/.github/workflows/code-style.yml index ca851eb..94b8d39 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.2 coverage: none tools: cs2pr, pint diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index d72e35b..cf71d63 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 ] + 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 5e41a8c..6e53c9a 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { - "name": "simplesquid/nova-enum-field", - "description": "A Laravel Nova field to add enums to resources.", - "keywords": [ + "name" : "simplesquid/nova-enum-field", + "description" : "A Laravel Nova field to add enums to resources.", + "keywords" : [ "simplesquid", "laravel", "nova", @@ -9,57 +9,57 @@ "enum", "nova-enum-field" ], - "homepage": "https://github.com/simplesquid/nova-enum-field", - "license": "MIT", - "authors": [ + "homepage" : "https://github.com/simplesquid/nova-enum-field", + "license" : "MIT", + "authors" : [ { - "name": "Matthew Poulter", - "email": "matthew.poulter@simplesquid.co.za", - "homepage": "https://simplesquid.co.za/", - "role": "Developer" + "name" : "Matthew Poulter", + "email" : "matthew.poulter@simplesquid.co.za", + "homepage" : "https://simplesquid.co.za/", + "role" : "Developer" } ], - "repositories": [ + "repositories" : [ { - "type": "composer", - "url": "https://nova.laravel.com" + "type" : "composer", + "url" : "https://nova.laravel.com" } ], - "require": { - "php": "^8.0", - "bensampo/laravel-enum": "^5.0 || ^6.0", - "illuminate/support": "^9.0 || ^10.0 || ^11.0", - "laravel/nova": "^4.0" + "require" : { + "php" : "^8.1", + "bensampo/laravel-enum" : "^5.0 || ^6.0", + "illuminate/support" : "^10.0 || ^11.0", + "laravel/nova" : "^4.0" }, - "require-dev": { - "joshgaber/novaunit": "^3.1", - "laravel/pint": "^1.2", - "mockery/mockery": "^1.3.3", - "nunomaduro/collision": "^6.1 || ^7.0 || ^8.0", - "orchestra/testbench": "^7.0 || ^8.0 || ^9.0", - "phpunit/phpunit": "^10.0", - "symfony/var-dumper": "^6.0" + "require-dev" : { + "joshgaber/novaunit" : "^3.1", + "laravel/pint" : "^1.2", + "mockery/mockery" : "^1.3.3", + "nunomaduro/collision" : "^7.0 || ^8.0", + "orchestra/testbench" : "^8.0 || ^9.0", + "phpunit/phpunit" : "^10.0", + "symfony/var-dumper" : "^6.0 || ^7.0" }, - "autoload": { - "psr-4": { - "SimpleSquid\\Nova\\Fields\\Enum\\": "src" + "autoload" : { + "psr-4" : { + "SimpleSquid\\Nova\\Fields\\Enum\\" : "src" } }, - "autoload-dev": { - "psr-4": { - "SimpleSquid\\Nova\\Fields\\Enum\\Tests\\": "tests" + "autoload-dev" : { + "psr-4" : { + "SimpleSquid\\Nova\\Fields\\Enum\\Tests\\" : "tests" } }, - "extra": { - "laravel": { - "providers": [] + "extra" : { + "laravel" : { + "providers" : [] } }, - "scripts": { - "test": "vendor/bin/phpunit --colors=always" + "scripts" : { + "test" : "vendor/bin/phpunit --colors=always" }, - "config": { - "sort-packages": true + "config" : { + "sort-packages" : true }, - "minimum-stability": "stable" + "minimum-stability" : "stable" } 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) From 583e238c16facc857948a9a09a72df0a2928f7c1 Mon Sep 17 00:00:00 2001 From: Matthew Poulter Date: Sun, 16 Jun 2024 16:09:35 +0200 Subject: [PATCH 3/7] Update phpunit.xml.dist --- phpunit.xml.dist | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index a34a972..535597c 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,24 +1,22 @@ - - - - tests/Fields - tests/Filters - - - - - - - - - - - - src - - + + + + tests/Fields + tests/Filters + + + + + + + + + + + + + src + + From d3be5abdb0443906fd1c218f380507560299ae41 Mon Sep 17 00:00:00 2001 From: Matthew Poulter Date: Tue, 15 Oct 2024 16:57:07 +0200 Subject: [PATCH 4/7] Use quotevelocity/novaunit --- .github/workflows/code-style.yml | 2 +- .github/workflows/run-tests.yml | 2 +- composer.json | 92 +++++++++++++++++--------------- phpunit.xml.dist | 16 +++--- 4 files changed, 60 insertions(+), 52 deletions(-) diff --git a/.github/workflows/code-style.yml b/.github/workflows/code-style.yml index 94b8d39..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.2 + php-version: 8.3 coverage: none tools: cs2pr, pint diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index cf71d63..712fe91 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -16,7 +16,7 @@ jobs: fail-fast: true matrix: os: [ ubuntu-latest ] - php: [ 8.2 ] + php: [ 8.2, 8.3 ] laravel: [ "^10.0", "^11.0" ] stability: [ prefer-lowest, prefer-stable ] include: diff --git a/composer.json b/composer.json index 6e53c9a..d71e5b3 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,8 @@ { - "name" : "simplesquid/nova-enum-field", - "description" : "A Laravel Nova field to add enums to resources.", - "keywords" : [ + "name": "simplesquid/nova-enum-field", + "description": "A Laravel Nova field to add enums to resources.", + "license": "MIT", + "keywords": [ "simplesquid", "laravel", "nova", @@ -9,57 +10,60 @@ "enum", "nova-enum-field" ], - "homepage" : "https://github.com/simplesquid/nova-enum-field", - "license" : "MIT", - "authors" : [ + "authors": [ { - "name" : "Matthew Poulter", - "email" : "matthew.poulter@simplesquid.co.za", - "homepage" : "https://simplesquid.co.za/", - "role" : "Developer" + "name": "Matthew Poulter", + "email": "matthew.poulter@simplesquid.co.za", + "homepage": "https://simplesquid.co.za/", + "role": "Developer" } ], - "repositories" : [ - { - "type" : "composer", - "url" : "https://nova.laravel.com" - } - ], - "require" : { - "php" : "^8.1", - "bensampo/laravel-enum" : "^5.0 || ^6.0", - "illuminate/support" : "^10.0 || ^11.0", - "laravel/nova" : "^4.0" + "homepage": "https://github.com/simplesquid/nova-enum-field", + "require": { + "php": "^8.1", + "bensampo/laravel-enum": "^5.0 || ^6.0", + "illuminate/support": "^10.0 || ^11.0", + "laravel/nova": "^4.0" }, - "require-dev" : { - "joshgaber/novaunit" : "^3.1", - "laravel/pint" : "^1.2", - "mockery/mockery" : "^1.3.3", - "nunomaduro/collision" : "^7.0 || ^8.0", - "orchestra/testbench" : "^8.0 || ^9.0", - "phpunit/phpunit" : "^10.0", - "symfony/var-dumper" : "^6.0 || ^7.0" + "require-dev": { + "ergebnis/composer-normalize": "^2.44", + "laravel/pint": "^1.2", + "mockery/mockery": "^1.3.3", + "nunomaduro/collision": "^7.0 || ^8.0", + "orchestra/testbench": "^8.0 || ^9.0", + "phpunit/phpunit": "^10.0", + "quotevelocity/novaunit": "^4.0", + "symfony/var-dumper": "^6.0 || ^7.0" }, - "autoload" : { - "psr-4" : { - "SimpleSquid\\Nova\\Fields\\Enum\\" : "src" + "repositories": [ + { + "type": "composer", + "url": "https://nova.laravel.com" } - }, - "autoload-dev" : { - "psr-4" : { - "SimpleSquid\\Nova\\Fields\\Enum\\Tests\\" : "tests" + ], + "minimum-stability": "stable", + "autoload": { + "psr-4": { + "SimpleSquid\\Nova\\Fields\\Enum\\": "src" } }, - "extra" : { - "laravel" : { - "providers" : [] + "autoload-dev": { + "psr-4": { + "SimpleSquid\\Nova\\Fields\\Enum\\Tests\\": "tests" } }, - "scripts" : { - "test" : "vendor/bin/phpunit --colors=always" + "config": { + "allow-plugins": { + "ergebnis/composer-normalize": true + }, + "sort-packages": true }, - "config" : { - "sort-packages" : true + "extra": { + "laravel": { + "providers": [] + } }, - "minimum-stability" : "stable" + "scripts": { + "test": "vendor/bin/phpunit --colors=always" + } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 535597c..31a496c 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,5 +1,9 @@ - + tests/Fields @@ -7,6 +11,11 @@ + + + src + + @@ -14,9 +23,4 @@ - - - src - - From dcf2efcd15fadf38f9316e37988adb84fba19515 Mon Sep 17 00:00:00 2001 From: Matthew Poulter Date: Tue, 15 Oct 2024 16:58:05 +0200 Subject: [PATCH 5/7] Linting --- tests/Fields/FieldTest.php | 2 +- tests/Fields/FlaggedFieldTest.php | 2 +- tests/Fields/IntegerFieldTest.php | 2 +- tests/Fields/NoCastsFieldTest.php | 2 +- tests/Fields/StringFieldTest.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/Fields/FieldTest.php b/tests/Fields/FieldTest.php index aac2099..a53adff 100644 --- a/tests/Fields/FieldTest.php +++ b/tests/Fields/FieldTest.php @@ -61,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); From 42ddf2a3fcc9083f486a0953f784692d253bba1c Mon Sep 17 00:00:00 2001 From: Matthew Poulter Date: Tue, 15 Oct 2024 16:59:41 +0200 Subject: [PATCH 6/7] Minimum versions --- .github/workflows/run-tests.yml | 4 ++-- composer.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 712fe91..331248b 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -17,13 +17,13 @@ jobs: matrix: os: [ ubuntu-latest ] php: [ 8.2, 8.3 ] - laravel: [ "^10.0", "^11.0" ] + laravel: [ "^10.0", "^11.1" ] stability: [ prefer-lowest, prefer-stable ] include: - laravel: "^10.0" testbench: "^8.0" enum: "^6.0" - - laravel: "^11.0" + - laravel: "^11.1" testbench: "^9.0" enum: "^6.0" diff --git a/composer.json b/composer.json index d71e5b3..eb93c3f 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "require": { "php": "^8.1", "bensampo/laravel-enum": "^5.0 || ^6.0", - "illuminate/support": "^10.0 || ^11.0", + "illuminate/support": "^10.0 || ^11.1", "laravel/nova": "^4.0" }, "require-dev": { @@ -31,7 +31,7 @@ "mockery/mockery": "^1.3.3", "nunomaduro/collision": "^7.0 || ^8.0", "orchestra/testbench": "^8.0 || ^9.0", - "phpunit/phpunit": "^10.0", + "phpunit/phpunit": "^10.1", "quotevelocity/novaunit": "^4.0", "symfony/var-dumper": "^6.0 || ^7.0" }, From 19efa23de17c4a952793a0a9d36a6059dc6da416 Mon Sep 17 00:00:00 2001 From: Matthew Poulter Date: Tue, 15 Oct 2024 17:13:12 +0200 Subject: [PATCH 7/7] Set collation rather --- .github/workflows/run-tests.yml | 4 ++-- composer.json | 2 +- phpunit.xml.dist | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 331248b..712fe91 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -17,13 +17,13 @@ jobs: matrix: os: [ ubuntu-latest ] php: [ 8.2, 8.3 ] - laravel: [ "^10.0", "^11.1" ] + laravel: [ "^10.0", "^11.0" ] stability: [ prefer-lowest, prefer-stable ] include: - laravel: "^10.0" testbench: "^8.0" enum: "^6.0" - - laravel: "^11.1" + - laravel: "^11.0" testbench: "^9.0" enum: "^6.0" diff --git a/composer.json b/composer.json index eb93c3f..18a475f 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "require": { "php": "^8.1", "bensampo/laravel-enum": "^5.0 || ^6.0", - "illuminate/support": "^10.0 || ^11.1", + "illuminate/support": "^10.0 || ^11.0", "laravel/nova": "^4.0" }, "require-dev": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 31a496c..62babd7 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -22,5 +22,6 @@ +