Filament tests failing with testbench 9.x
Closed this issue · 2 comments
- Testbench Version: 9.x-dev c1a5b1f
- Laravel Version: dev-master 39561b1
- PHP Version: 8.3.3
- Database Driver & Version: sqlite :memory:
Description:
We've been working on dependencies supporting Laravel 11 to be able to support it in Filament. filamentphp/filament#10972
Now the dependencies are ok, but most tests fail with this error:
FAILED Tests\src\Actions\ActionTest > it can call an action with data PDOException
There is already an active transaction
at vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php:150
146▕ if ($this->transactions == 0) {
147▕ $this->reconnectIfMissingConnection();
148▕
149▕ try {
➜ 150▕ $this->getPdo()->beginTransaction();
151▕ } catch (Throwable $e) {
152▕ $this->handleBeginTransactionException($e);
153▕ }
154▕ } elseif ($this->transactions >= 1 && $this->queryGrammar->supportsSavepoints()) {
I checked out the PRs and commits of laravel/framework, but none of them seemed to have caused the issue. I'm guessing it's a testbench issue, specially after going through this PR laravel/framework#49385
Can you please shed some light?
Steps To Reproduce:
git clone git@github.com:filamentphp/filament.git && cd filament
git checkout laravel-11
composer install
composer test
laravel/framework#49385 is not merged yet and has nothing to do with this issue.
In Laravel 11, RefreshDatabase
and LazilyRefreshDatabase
combined with in-memory database will keep PDO instances between tests and is the root cause of this issue. You would need to reset RefreshDatabaseState
between tests.