diff --git a/Classes/Core/Testbase.php b/Classes/Core/Testbase.php index 9b04635d..e8885df9 100644 --- a/Classes/Core/Testbase.php +++ b/Classes/Core/Testbase.php @@ -668,10 +668,14 @@ public function setUpPackageStates( public function setUpTestDatabase(string $databaseName, string $originalDatabaseName): void { // First close existing connections from a possible previous test case and - // tell our ConnectionPool there are no current connections anymore. + // tell our ConnectionPool there are no current connections anymore. In case + // database does not exist yet, an exception is thrown which we catch here. $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class); - $connection = $connectionPool->getConnectionByName(ConnectionPool::DEFAULT_CONNECTION_NAME); - $connection->close(); + try { + $connection = $connectionPool->getConnectionByName(ConnectionPool::DEFAULT_CONNECTION_NAME); + $connection->close(); + } catch (DBALException) { + } $connectionPool->resetConnections(); // Drop database if exists. Directly using the Doctrine DriverManager to @@ -689,8 +693,8 @@ public function setUpTestDatabase(string $databaseName, string $originalDatabase $configuration->setSchemaManagerFactory($coreSchemaFactory); } $driverConnection = DriverManager::getConnection($connectionParameters, $configuration); + $schemaManager = $driverConnection->createSchemaManager(); - $platform = $driverConnection->getDatabasePlatform(); $isSQLite = self::isSQLite($driverConnection); // doctrine/dbal no longer supports createDatabase() and dropDatabase() statements. Guard it.