-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Description
- Laravel-mongodb Version: 5.5.0
- PHP Version: 8.4.4
- Database Driver & Version: mongodb/mongodb 2.1.1
Description:
Using DB::enableQueryLog
within a test that is using the DatabaseMigrations
trait fails with an error Call to a member function addSubscriber() on null
The laravel-mongodb version of enableQueryLog
is trying to access the connection
property on the Connection
class (see here). However since Laravel 12.22 the connection is disconnected after the database wipe, as part of the db migration within DatabaseMigrations
, so the connection
property is null. See Laravel PR 56368
Steps to reproduce
- Create unit test (PHPUnit or Pest) using
DatabaseMigrations
trait - Add
DB::enableQueryLog
, either within the test or within the code - Run the test
Expected behaviour
Query log should be enabled, and results should be visible from DB::getQueryLog
Actual behaviour
Test errors
Error: Call to a member function addSubscriber() on null
at vendor/mongodb/laravel-mongodb/src/Connection.php:186
at vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php:489
at vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:363
Metadata
Metadata
Assignees
Labels
No labels