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

feat: Laravel 11.x Compatibility #21

Merged
merged 23 commits into from
Mar 14, 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
11 changes: 7 additions & 4 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,19 @@ jobs:
fail-fast: true
matrix:
os: [ ubuntu-latest ]
php: [ 8.1, 8.2 ]
laravel: [ 8.*, 9.*, 10.* ]
php: [ 8.1, 8.2, 8.3 ]
laravel: [ 9.*, 10.*, 11.* ]
stability: [ prefer-lowest, prefer-stable ]
include:
- laravel: 8.*
testbench: ^6.23
- laravel: 9.*
testbench: ^7.0
- laravel: 10.*
testbench: ^8.0
- laravel: 11.*
testbench: ^9.0
exclude:
- php: 8.1
laravel: 11.*

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}

Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ node_modules
node_modules.nosync
.php-cs-fixer.cache
.DS_Store
.phpunit.cache
phpunit.xml.dist.bak
15 changes: 8 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,18 @@
"require": {
"php": "^8.0",
"filament/filament": "^3.0",
"illuminate/contracts": "^8.73|^9.0|^10.0",
"illuminate/contracts": "^9.52|^10.0|^11.0",
"ralphjsmit/laravel-seo": "^1.0.4",
"spatie/laravel-package-tools": "^1.9.2"
},
"require-dev": {
"nesbot/carbon": "^2.66",
"nunomaduro/collision": "^5.10|^6.1|^7.0",
"orchestra/testbench": "^6.22|^7.0|^8.0",
"pestphp/pest": "^1.21",
"pestphp/pest-plugin-laravel": "^1.1",
"phpunit/phpunit": "^9.5",
"doctrine/dbal": "^3.8",
"nesbot/carbon": "^2.66|^3.0",
"nunomaduro/collision": "^6.1|^7.0|^8.0",
"orchestra/testbench": "^7.0|^8.0|^9.0",
"pestphp/pest": "^1.21|^2.0",
"pestphp/pest-plugin-laravel": "^1.1|^2.0",
"phpunit/phpunit": "^9.5|^10.5",
"spatie/laravel-ray": "^1.26"
},
"autoload": {
Expand Down
46 changes: 14 additions & 32 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,34 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
executionOrder="random"
failOnWarning="true"
failOnRisky="true"
failOnEmptyTestSuite="true"
beStrictAboutOutputDuringTests="true"
verbose="true"
>
<testsuites>
<testsuite name="RalphJSmit Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<include>
<directory suffix=".php">./src</directory>
</include>
</coverage>
<php>
<env name="APP_KEY" value="AckfSECXIvnK5r28GVIWUAxmbBSjTsmF"/>
</php>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" executionOrder="random" failOnWarning="true" failOnRisky="true" failOnEmptyTestSuite="true" beStrictAboutOutputDuringTests="true" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<testsuites>
<testsuite name="RalphJSmit Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<php>
<env name="APP_KEY" value="AckfSECXIvnK5r28GVIWUAxmbBSjTsmF"/>
</php>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
</phpunit>
3 changes: 1 addition & 2 deletions tests/Pest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php

use Illuminate\Foundation\Testing\RefreshDatabase;
use RalphJSmit\Filament\SEO\Tests\TestCase;

uses(TestCase::class, RefreshDatabase::class)->in(__DIR__);
uses(TestCase::class)->in(__DIR__);
27 changes: 20 additions & 7 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
use Filament\Forms\FormsServiceProvider;
use Filament\Support\SupportServiceProvider;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\View;
use Livewire\LivewireServiceProvider;
use Orchestra\Testbench\TestCase as Orchestra;
Expand All @@ -14,14 +16,25 @@

class TestCase extends Orchestra
{
use RefreshDatabase;

protected function setUp(): void
{
parent::setUp();

Factory::guessFactoryNamesUsing(fn (string $modelName) => 'RalphJSmit\\Filament\\SEO\\Database\\Factories\\' . class_basename($modelName) . 'Factory');

View::addLocation(__DIR__ . '/Fixtures/resources/views');

// Laravel 11 changed the way database migrations are loaded and removed the Doctrine DBAL dependency.
// That behaviour broke the previous way of running tests using `getEnvironmentSetUp()`.
if (version_compare(Application::VERSION, '11', '>=')) {
(include __DIR__ . '/Fixtures/migrations/create_test_tables.php')->up();
(include __DIR__ . '/../vendor/ralphjsmit/laravel-seo/database/migrations/create_seo_table.php.stub')->up();
}
}

protected function getPackageProviders($app)
protected function getPackageProviders($app): array
{
return [
LivewireServiceProvider::class,
Expand All @@ -33,13 +46,13 @@ protected function getPackageProviders($app)
];
}

public function getEnvironmentSetUp($app)
protected function getEnvironmentSetUp($app): void
{
config()->set('database.default', 'testing');

View::addLocation(__DIR__ . '/Fixtures/resources/views');
if (version_compare(Application::VERSION, '11', '<')) {
config()->set('database.default', 'testing');

(include __DIR__ . '/Fixtures/migrations/create_test_tables.php')->up();
(include __DIR__ . '/../vendor/ralphjsmit/laravel-seo/database/migrations/create_seo_table.php.stub')->up();
(include __DIR__ . '/Fixtures/migrations/create_test_tables.php')->up();
(include __DIR__ . '/../vendor/ralphjsmit/laravel-seo/database/migrations/create_seo_table.php.stub')->up();
}
}
}
Loading