/**
  * Handle SUITE_BEFORE event.
  *
  * Create a full standalone TYPO3 instance within typo3temp/var/tests/acceptance,
  * create a database and create database schema.
  *
  * @param SuiteEvent $suiteEvent
  * @throws Exception
  */
 public function bootstrapTypo3Environment(SuiteEvent $suiteEvent)
 {
     $testbase = new Testbase();
     $testbase->enableDisplayErrors();
     $testbase->defineBaseConstants();
     $testbase->defineOriginalRootPath();
     $testbase->createDirectory(ORIGINAL_ROOT . 'typo3temp/var/tests/acceptance');
     $testbase->createDirectory(ORIGINAL_ROOT . 'typo3temp/var/transient');
     $instancePath = ORIGINAL_ROOT . 'typo3temp/var/tests/acceptance';
     $testbase->defineTypo3ModeBe();
     $testbase->setTypo3TestingContext();
     $testbase->removeOldInstanceIfExists($instancePath);
     // Basic instance directory structure
     $testbase->createDirectory($instancePath . '/fileadmin');
     $testbase->createDirectory($instancePath . '/typo3temp/var/transient');
     $testbase->createDirectory($instancePath . '/typo3temp/assets');
     $testbase->createDirectory($instancePath . '/typo3conf/ext');
     $testbase->createDirectory($instancePath . '/uploads');
     // Additionally requested directories
     foreach ($this->additionalFoldersToCreate as $directory) {
         $testbase->createDirectory($instancePath . '/' . $directory);
     }
     $testbase->createLastRunTextfile($instancePath);
     $testbase->setUpInstanceCoreLinks($instancePath);
     // ext:styleguide is always loaded
     $testExtensionsToLoad = array_merge(['typo3conf/ext/styleguide'], $this->testExtensionsToLoad);
     $testbase->linkTestExtensionsToInstance($instancePath, $testExtensionsToLoad);
     $testbase->linkPathsInTestInstance($instancePath, $this->pathsToLinkInTestInstance);
     $localConfiguration = $testbase->getOriginalDatabaseSettingsFromEnvironmentOrLocalConfiguration();
     $originalDatabaseName = $localConfiguration['DB']['Connections']['Default']['dbname'];
     // Append the unique identifier to the base database name to end up with a single database per test case
     $localConfiguration['DB']['Connections']['Default']['dbname'] = $originalDatabaseName . '_at';
     $testbase->testDatabaseNameIsNotTooLong($originalDatabaseName, $localConfiguration);
     // Set some hard coded base settings for the instance. Those could be overruled by
     // $this->configurationToUseInTestInstance if needed again.
     $localConfiguration['BE']['debug'] = true;
     $localConfiguration['BE']['lockHashKeyWords'] = '';
     $localConfiguration['BE']['installToolPassword'] = '******';
     $localConfiguration['SYS']['isInitialInstallationInProgress'] = false;
     $localConfiguration['SYS']['isInitialDatabaseImportDone'] = true;
     $localConfiguration['SYS']['displayErrors'] = false;
     $localConfiguration['SYS']['debugExceptionHandler'] = '';
     $localConfiguration['SYS']['trustedHostsPattern'] = 'localhost:8000';
     $localConfiguration['SYS']['encryptionKey'] = 'iAmInvalid';
     // @todo: This sql_mode should be enabled as soon as styleguide and dataHandler can cope with it
     //$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\';';
     $localConfiguration['SYS']['caching']['cacheConfigurations']['extbase_object']['backend'] = NullBackend::class;
     $testbase->setUpLocalConfiguration($instancePath, $localConfiguration, $this->configurationToUseInTestInstance);
     $defaultCoreExtensionsToLoad = ['core', 'extbase', 'fluid', 'filelist', 'extensionmanager', 'lang', 'setup', 'rsaauth', 'saltedpasswords', 'backend', 'belog', 'install', 't3skin', 'frontend', 'recordlist', 'reports', 'sv', 'scheduler'];
     $testbase->setUpPackageStates($instancePath, $defaultCoreExtensionsToLoad, $this->coreExtensionsToLoad, $testExtensionsToLoad);
     $testbase->setUpBasicTypo3Bootstrap($instancePath);
     $testbase->setUpTestDatabase($localConfiguration['DB']['Connections']['Default']['dbname'], $originalDatabaseName);
     $testbase->loadExtensionTables();
     $testbase->createDatabaseStructure();
     // Unset a closure or phpunit kicks in with a 'serialization of \Closure is not allowed'
     // Alternative solution:
     // unset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['cliKeys']['extbase']);
     $suite = $suiteEvent->getSuite();
     $suite->setBackupGlobals(false);
     foreach ($this->xmlDatabaseFixtures as $fixture) {
         $testbase->importXmlDatabaseFixture(ORIGINAL_ROOT . $fixture);
     }
     // styleguide generator uses DataHandler for some parts. DataHandler needs an initialized BE user
     // with admin right and the live workspace.
     Bootstrap::getInstance()->initializeBackendUser();
     $GLOBALS['BE_USER']->user['admin'] = 1;
     $GLOBALS['BE_USER']->user['uid'] = 1;
     $GLOBALS['BE_USER']->workspace = 0;
     Bootstrap::getInstance()->initializeLanguageObject();
     $styleguideGenerator = new Generator();
     $styleguideGenerator->create();
 }
Example #2
0
 /**
  * Imports a data set represented as XML into the test database,
  *
  * @param string $path Absolute path to the XML file containing the data set to load
  * @return void
  * @throws Exception
  */
 protected function importDataSet($path)
 {
     $testbase = new Testbase();
     $testbase->importXmlDatabaseFixture($path);
 }