diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 8514b3f..995f69c 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -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 }} diff --git a/.gitignore b/.gitignore index 3eddbee..844f624 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,5 @@ node_modules node_modules.nosync .php-cs-fixer.cache .DS_Store +.phpunit.cache +phpunit.xml.dist.bak diff --git a/composer.json b/composer.json index 0903f13..b1e7217 100644 --- a/composer.json +++ b/composer.json @@ -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": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 3512fcd..5021e66 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,34 +1,16 @@ - - - - tests - - - - - ./src - - - - - + + + + tests + + + + + + + + ./src + + diff --git a/tests/Pest.php b/tests/Pest.php index 56024e3..67f8829 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -1,6 +1,5 @@ in(__DIR__); +uses(TestCase::class)->in(__DIR__); diff --git a/tests/TestCase.php b/tests/TestCase.php index 260bbe6..17f05ce 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -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; @@ -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, @@ -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(); + } } }