From 5b465c27133a54a2463b3df24bd71753731ac6a8 Mon Sep 17 00:00:00 2001 From: Stephen Jude Date: Sun, 31 May 2026 02:05:35 +0100 Subject: [PATCH] fix: set current panel in tests for Filament v5 compatibility In Filament v5 the current panel is only set by the SetUpPanel middleware during HTTP requests, so filament()->getCurrentPanel() returned null in unit tests and the "registers plugin" test failed with "Call to a member function plugin() on null". Also migrate phpunit.xml.dist to the PHPUnit 11/12 schema and ignore the new .phpunit.cache directory. --- .gitignore | 1 + phpunit.xml.dist | 58 +++++++++++++++++----------------------------- tests/TestCase.php | 3 +++ 3 files changed, 25 insertions(+), 37 deletions(-) diff --git a/.gitignore b/.gitignore index 83c9b9f..df1e984 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .idea +.phpunit.cache .phpunit.result.cache build composer.lock diff --git a/phpunit.xml.dist b/phpunit.xml.dist index e859be2..e952628 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,39 +1,23 @@ - - - - tests - - - - - ./src - - - - - - - - - - + + + + tests + + + + + + + + + + + + + + + ./src + + diff --git a/tests/TestCase.php b/tests/TestCase.php index 6bb273b..9ca4214 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -4,6 +4,7 @@ use BladeUI\Heroicons\BladeHeroiconsServiceProvider; use BladeUI\Icons\BladeIconsServiceProvider; +use Filament\Facades\Filament; use Filament\FilamentServiceProvider; use Livewire\LivewireServiceProvider; use Orchestra\Testbench\TestCase as Orchestra; @@ -15,6 +16,8 @@ class TestCase extends Orchestra protected function setUp(): void { parent::setUp(); + + Filament::setCurrentPanel('admin'); } protected function getPackageProviders($app)