Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 32 additions & 4 deletions Classes/Core/Functional/FunctionalTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ protected function setUp(): void
$testbase->linkFrameworkExtensionsToInstance($this->instancePath, $frameworkExtension);
$testbase->linkPathsInTestInstance($this->instancePath, $this->pathsToLinkInTestInstance);
$testbase->providePathsInTestInstance($this->instancePath, $this->pathsToProvideInTestInstance);
$localConfiguration = [];
$localConfiguration['DB'] = $testbase->getOriginalDatabaseSettingsFromEnvironmentOrLocalConfiguration();

$originalDatabaseName = '';
Expand All @@ -321,15 +322,42 @@ protected function setUp(): void
$localConfiguration['DB']['Connections']['Default']['dbname'] = $dbName;
$testbase->testDatabaseNameIsNotTooLong($originalDatabaseName, $localConfiguration);
if ($dbDriver === 'mysqli' || $dbDriver === 'pdo_mysql') {
$localConfiguration['DB']['Connections']['Default']['charset'] = 'utf8mb4';
$localConfiguration['DB']['Connections']['Default']['tableoptions']['charset'] = 'utf8mb4';
$localConfiguration['DB']['Connections']['Default']['tableoptions']['collate'] = 'utf8mb4_unicode_ci';
$localConfiguration['DB']['Connections']['Default']['initCommands'] = 'SET SESSION sql_mode = \'STRICT_ALL_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_VALUE_ON_ZERO,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ONLY_FULL_GROUP_BY\';';
// MySQL/MariaDB allows more specific settings, and default configuration specific to these
// platforms are handled here. That includes using the more specific `utf8mb4` charset like
// TYPO3 would determine and write during installation and also defining `defaultTableOptions`
// based on selected charset.
if (($localConfiguration['DB']['Connections']['Default']['charset'] ?? '') === '') {
$localConfiguration['DB']['Connections']['Default']['charset'] = 'utf8mb4';
}
if (($localConfiguration['DB']['Connections']['Default']['defaultTableOptions']['charset'] ?? '') === '') {
$localConfiguration['DB']['Connections']['Default']['defaultTableOptions']['charset'] = 'utf8mb4';
}
if (($localConfiguration['DB']['Connections']['Default']['defaultTableOptions']['collation'] ?? '') === '') {
$localConfiguration['DB']['Connections']['Default']['defaultTableOptions']['collation']
= $localConfiguration['DB']['Connections']['Default']['defaultTableOptions']['charset'] . '_unicode_ci';
}
$localConfiguration['DB']['Connections']['Default']['initCommands']
= 'SET SESSION sql_mode = \'' . implode(',', [
'STRICT_ALL_TABLES',
'ERROR_FOR_DIVISION_BY_ZERO',
'NO_AUTO_VALUE_ON_ZERO',
'NO_ENGINE_SUBSTITUTION',
'NO_ZERO_DATE',
'NO_ZERO_IN_DATE',
'ONLY_FULL_GROUP_BY',
]) . '\';';
}
// Postgres/SQLite requires to use `utf-8` as charset and does not support `utf8mb4`.
if (($localConfiguration['DB']['Connections']['Default']['charset'] ?? '') === '') {
$localConfiguration['DB']['Connections']['Default']['charset'] = 'utf-8';
}
} else {
// sqlite dbs of all tests are stored in a dir parallel to instance roots. Allows defining this path as tmpfs.
$testbase->createDirectory(dirname($this->instancePath) . '/functional-sqlite-dbs');
$localConfiguration['DB']['Connections']['Default']['path'] = $dbPathSqlite;
if (($localConfiguration['DB']['charset'] ?? '') === '') {
$localConfiguration['DB']['charset'] = 'utf-8';
}
}

// Set some hard coded base settings for the instance. Those could be overruled by
Expand Down