diff --git a/src/Migrator.php b/src/Migrator.php index df3245d..39e0e98 100644 --- a/src/Migrator.php +++ b/src/Migrator.php @@ -319,7 +319,7 @@ private function getDatabases(): iterable if ($this->dbal instanceof DatabaseManager) { return array_filter( $this->dbal->getDatabases(), - fn (DatabaseInterface $db): bool => !$db->getDriver()->getSchemaHandler() instanceof ReadonlyHandler + fn (DatabaseInterface $db): bool => !$db->getDriver()->isReadonly() ); } return []; diff --git a/tests/Migrations/Unit/IsolatedMigratorTest.php b/tests/Migrations/Unit/IsolatedMigratorTest.php new file mode 100644 index 0000000..a00d6d5 --- /dev/null +++ b/tests/Migrations/Unit/IsolatedMigratorTest.php @@ -0,0 +1,44 @@ +addDatabase( + new Database( + 'foo', + '', + $driver = $this->createMock(DriverInterface::class), + ), + ); + $driver->expects($this->atLeastOnce())->method('isReadonly')->willReturn(true); + $driver + ->expects($this->any()) + ->method($this->callback(fn($name) => $name !== 'isReadonly')) + ->willThrowException(new \RuntimeException('Unexpected method call')); + + $repository = $this->createMock(RepositoryInterface::class); + + $migrator = new Migrator( + new MigrationConfig([]), + $dbal, + $repository, + ); + + $migrator->isConfigured(); + } +}