diff --git a/Classes/Core/Functional/Framework/DataHandling/Snapshot/DatabaseSnapshot.php b/Classes/Core/Functional/Framework/DataHandling/Snapshot/DatabaseSnapshot.php index 3e832a30..6e11e66f 100644 --- a/Classes/Core/Functional/Framework/DataHandling/Snapshot/DatabaseSnapshot.php +++ b/Classes/Core/Functional/Framework/DataHandling/Snapshot/DatabaseSnapshot.php @@ -18,6 +18,7 @@ namespace TYPO3\TestingFramework\Core\Functional\Framework\DataHandling\Snapshot; use Doctrine\DBAL\Connection; +use Doctrine\DBAL\Platforms\SqlitePlatform as DoctrineSQLitePlatform; /** * Implement the database snapshot and callback logic. @@ -61,7 +62,7 @@ private function __construct(string $sqliteDir, string $identifier) */ public function create(DatabaseAccessor $accessor, Connection $connection): void { - if ($connection->getDatabasePlatform()->getName() === 'sqlite') { + if ($connection->getDatabasePlatform() instanceof DoctrineSQLitePlatform) { // With sqlite, we simply copy the db-file to a different place $connection->close(); copy( @@ -87,7 +88,7 @@ public function create(DatabaseAccessor $accessor, Connection $connection): void */ public function restore(DatabaseAccessor $accessor, Connection $connection): void { - if ($connection->getDatabasePlatform()->getName() === 'sqlite') { + if ($connection->getDatabasePlatform() instanceof DoctrineSQLitePlatform) { $connection->close(); copy( $this->sqliteDir . 'test_' . $this->identifier . '.snapshot.sqlite', diff --git a/Classes/Core/Functional/FunctionalTestCase.php b/Classes/Core/Functional/FunctionalTestCase.php index f1afa60b..ae7058a9 100644 --- a/Classes/Core/Functional/FunctionalTestCase.php +++ b/Classes/Core/Functional/FunctionalTestCase.php @@ -17,7 +17,7 @@ * The TYPO3 project - inspiring people to share! */ -use Doctrine\DBAL\Platforms\PostgreSQLPlatform; +use Doctrine\DBAL\Platforms\PostgreSQLPlatform as DoctrinePostgreSQLPlatform; use PHPUnit\Framework\ExpectationFailedException; use Psr\Container\ContainerInterface; use Psr\Http\Message\ResponseInterface; @@ -855,7 +855,7 @@ protected function setUpFrontendRootPage(int $pageId, array $typoScriptFiles = [ } // @todo: Check if this constant is still needed $databasePlatform = 'mysql'; - if ($connection->getDatabasePlatform() instanceof PostgreSQLPlatform) { + if ($connection->getDatabasePlatform() instanceof DoctrinePostgreSQLPlatform) { $databasePlatform = 'postgresql'; } $templateFields['constants'] .= 'databasePlatform = ' . $databasePlatform . LF; diff --git a/Classes/Core/Testbase.php b/Classes/Core/Testbase.php index eb5d3857..725ac014 100644 --- a/Classes/Core/Testbase.php +++ b/Classes/Core/Testbase.php @@ -19,9 +19,10 @@ use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\Exception as DBALException; -use Doctrine\DBAL\Platforms\MySQLPlatform; -use Doctrine\DBAL\Platforms\PostgreSQLPlatform; -use Doctrine\DBAL\Platforms\SqlitePlatform; +use Doctrine\DBAL\Platforms\MariaDBPlatform as DoctrineMariaDBPlatform; +use Doctrine\DBAL\Platforms\MySQLPlatform as DoctrineMySQLPlatform; +use Doctrine\DBAL\Platforms\PostgreSQLPlatform as DoctrinePostgreSQLPlatform; +use Doctrine\DBAL\Platforms\SqlitePlatform as DoctrineSQLitePlatform; use Psr\Container\ContainerInterface; use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; use TYPO3\CMS\Core\Core\Bootstrap; @@ -662,8 +663,10 @@ public function setUpTestDatabase(string $databaseName, string $originalDatabase unset($connectionParameters['dbname']); $connection = DriverManager::getConnection($connectionParameters); $schemaManager = $connection->createSchemaManager(); + $platform = $connection->getDatabasePlatform(); + $isSQLite = $platform instanceof DoctrineSQLitePlatform; - if ($connection->getDatabasePlatform()->getName() === 'sqlite') { + if ($isSQLite) { // This is the "path" option in sqlite: one file = one db $schemaManager->dropDatabase($databaseName); } elseif (in_array($databaseName, $schemaManager->listDatabases(), true)) { @@ -742,7 +745,7 @@ public function initializeTestDatabaseAndTruncateTables(string $dbPathSqlite = ' $connection = GeneralUtility::makeInstance(ConnectionPool::class) ->getConnectionByName(ConnectionPool::DEFAULT_CONNECTION_NAME); $platform = $connection->getDatabasePlatform(); - if ($platform instanceof MySQLPlatform) { + if ($platform instanceof DoctrineMariaDBPlatform || $platform instanceof DoctrineMySQLPlatform) { $this->truncateAllTablesForMysql(); } else { $this->truncateAllTablesForOtherDatabases(); @@ -866,7 +869,7 @@ public function createDatabaseStructure(ContainerInterface $container): void public static function resetTableSequences(Connection $connection, string $tableName): void { $platform = $connection->getDatabasePlatform(); - if ($platform instanceof PostgreSqlPlatform) { + if ($platform instanceof DoctrinePostgreSQLPlatform) { $queryBuilder = $connection->createQueryBuilder(); $queryBuilder->getRestrictions()->removeAll(); $row = $queryBuilder->select('PGT.schemaname', 'S.relname', 'C.attname', 'T.relname AS tablename') @@ -897,7 +900,7 @@ public static function resetTableSequences(Connection $connection, string $table ) ); } - } elseif ($platform instanceof SqlitePlatform) { + } elseif ($platform instanceof DoctrineSQLitePlatform) { // Drop eventually existing sqlite sequence for this table $connection->executeStatement( sprintf(