+
+ // Use a 7 char long hash of class name as identifier
+ $this->identifier = substr(sha1(get_class($this)), 0, 7);
+ $this->instancePath = ORIGINAL_ROOT . 'typo3temp/var/tests/functional-' . $this->identifier;
+
+ $testbase = new Testbase();
+ $testbase->defineTypo3ModeBe();
+ $testbase->setTypo3TestingContext();
+ if ($testbase->recentTestInstanceExists($this->instancePath)) {
+ // Reusing an existing instance. This typically happens for the second, third, ... test
+ // in a test case, so environment is set up only once per test case.
+ $testbase->setUpBasicTypo3Bootstrap($this->instancePath);
+ $testbase->initializeTestDatabaseAndTruncateTables();
+ $testbase->loadExtensionTables();
+ } else {
+ $testbase->removeOldInstanceIfExists($this->instancePath);
+ // Basic instance directory structure
+ $testbase->createDirectory($this->instancePath . '/fileadmin');
+ $testbase->createDirectory($this->instancePath . '/typo3temp/var/transient');
+ $testbase->createDirectory($this->instancePath . '/typo3temp/assets');
+ $testbase->createDirectory($this->instancePath . '/typo3conf/ext');
+ $testbase->createDirectory($this->instancePath . '/uploads');
+ // Additionally requested directories
+ foreach ($this->additionalFoldersToCreate as $directory) {
+ $testbase->createDirectory($this->instancePath . '/' . $directory);
+ }
+ $testbase->createLastRunTextfile($this->instancePath);
+ $testbase->setUpInstanceCoreLinks($this->instancePath);
+ $testbase->linkTestExtensionsToInstance($this->instancePath, $this->testExtensionsToLoad);
+ $testbase->linkPathsInTestInstance($this->instancePath, $this->pathsToLinkInTestInstance);
+ $localConfiguration = $testbase->getOriginalDatabaseSettingsFromEnvironmentOrLocalConfiguration();
+ $originalDatabaseName = $localConfiguration['DB']['database'];
+ // Append the unique identifier to the base database name to end up with a single database per test case
+ $localConfiguration['DB']['database'] = $originalDatabaseName . '_ft' . $this->identifier;
+ $testbase->testDatabaseNameIsNotTooLong($originalDatabaseName, $localConfiguration);
+ // Set some hard coded base settings for the instance. Those could be overruled by
+ // $this->configurationToUseInTestInstance if needed again.
+ $localConfiguration['SYS']['isInitialInstallationInProgress'] = false;
+ $localConfiguration['SYS']['isInitialDatabaseImportDone'] = true;
+ $localConfiguration['SYS']['displayErrors'] = '1';
+ $localConfiguration['SYS']['debugExceptionHandler'] = '';
+ $localConfiguration['SYS']['trustedHostsPattern'] = '.*';
+ $localConfiguration['SYS']['setDBinit'] = '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\';';
+ $testbase->setUpLocalConfiguration($this->instancePath, $localConfiguration, $this->configurationToUseInTestInstance);
+ $defaultCoreExtensionsToLoad = [
+ 'core',
+ 'backend',
+ 'frontend',
+ 'lang',
+ 'extbase',
+ 'install',
+ ];
+ $testbase->setUpPackageStates($this->instancePath, $defaultCoreExtensionsToLoad, $this->coreExtensionsToLoad, $this->testExtensionsToLoad);
+ $testbase->setUpBasicTypo3Bootstrap($this->instancePath);
+ $testbase->setUpTestDatabase($localConfiguration['DB']['database'], $originalDatabaseName);
+ $testbase->loadExtensionTables();
+ $testbase->createDatabaseStructure();
+ }