Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Laravel 11 #58

Merged
merged 7 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/code-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 5 additions & 8 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down
44 changes: 24 additions & 20 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "simplesquid/nova-enum-field",
"description": "A Laravel Nova field to add enums to resources.",
"license": "MIT",
"keywords": [
"simplesquid",
"laravel",
Expand All @@ -9,8 +10,6 @@
"enum",
"nova-enum-field"
],
"homepage": "https://github.com/simplesquid/nova-enum-field",
"license": "MIT",
"authors": [
{
"name": "Matthew Poulter",
Expand All @@ -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"
Expand All @@ -50,16 +52,18 @@
"SimpleSquid\\Nova\\Fields\\Enum\\Tests\\": "tests"
}
},
"config": {
"allow-plugins": {
"ergebnis/composer-normalize": true
},
"sort-packages": true
},
"extra": {
"laravel": {
"providers": []
}
},
"scripts": {
"test": "vendor/bin/phpunit --colors=always"
},
"config": {
"sort-packages": true
},
"minimum-stability": "stable"
}
}
17 changes: 10 additions & 7 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true">
<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
colors="true"
>
<testsuites>
<testsuite name="Simple Squid Test Suite">
<directory>tests/Fields</directory>
<directory>tests/Filters</directory>
</testsuite>
</testsuites>
<coverage/>
<source>
<include>
<directory>src</directory>
</include>
</source>
<php>
<env name="DB_CONNECTION" value="mysql"/>
<env name="DB_USERNAME" value="root"/>
<env name="DB_DATABASE" value="nova_enum_field"/>
<env name="DB_HOST" value="127.0.0.1"/>
<env name="DB_PORT" value="3306"/>
<env name="DB_COLLATION" value="utf8mb4_unicode_ci"/>
</php>
</phpunit>
2 changes: 1 addition & 1 deletion src/Enum.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions tests/Fields/FieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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));
}
}
2 changes: 1 addition & 1 deletion tests/Fields/FlaggedFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tests/Fields/IntegerFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tests/Fields/NoCastsFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tests/Fields/StringFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading