- /**
- * Returns the parameters that will be used when Simpletest installs Drupal.
- *
- * @see install_drupal()
- * @see install_state_defaults()
- */
- protected function installParameters() {
- $connection_info = Database::getConnectionInfo();
- $driver = $connection_info['default']['driver'];
- $connection_info['default']['prefix'] = $connection_info['default']['prefix']['default'];
- unset($connection_info['default']['driver']);
- unset($connection_info['default']['namespace']);
- unset($connection_info['default']['pdo']);
- unset($connection_info['default']['init_commands']);
- $parameters = [
- 'interactive' => FALSE,
- 'parameters' => [
- 'profile' => $this->profile,
- 'langcode' => 'en',
- ],
- 'forms' => [
- 'install_settings_form' => [
- 'driver' => $driver,
- $driver => $connection_info['default'],
- ],
- 'install_configure_form' => [
- 'site_name' => 'Drupal',
- 'site_mail' => 'simpletest@example.com',
- 'account' => [
- 'name' => $this->rootUser->name,
- 'mail' => $this->rootUser->getEmail(),
- 'pass' => [
- 'pass1' => $this->rootUser->pass_raw,
- 'pass2' => $this->rootUser->pass_raw,
- ],
- ],
- // form_type_checkboxes_value() requires NULL instead of FALSE values
- // for programmatic form submissions to disable a checkbox.
- 'enable_update_status_module' => NULL,
- 'enable_update_status_emails' => NULL,
- ],
- ],
- ];
- return $parameters;
- }
-
- /**
- * Prepares the current environment for running the test.
- *
- * Also sets up new resources for the testing environment, such as the public
- * filesystem and configuration directories.
- *
- * This method is private as it must only be called once by
- * BrowserTestBase::setUp() (multiple invocations for the same test would have
- * unpredictable consequences) and it must not be callable or overridable by
- * test classes.
- */
- protected function prepareEnvironment() {
- // Bootstrap Drupal so we can use Drupal's built in functions.
- $this->classLoader = require __DIR__ . '/../../../../autoload.php';
- $request = Request::createFromGlobals();
- $kernel = TestRunnerKernel::createFromRequest($request, $this->classLoader);
- // TestRunnerKernel expects the working directory to be DRUPAL_ROOT.
- chdir(DRUPAL_ROOT);
- $kernel->prepareLegacyRequest($request);
- $this->prepareDatabasePrefix();
-
- $this->originalSite = $kernel->findSitePath($request);
-
- // Create test directory ahead of installation so fatal errors and debug
- // information can be logged during installation process.
- file_prepare_directory($this->siteDirectory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
-
- // Prepare filesystem directory paths.
- $this->publicFilesDirectory = $this->siteDirectory . '/files';
- $this->privateFilesDirectory = $this->siteDirectory . '/private';
- $this->tempFilesDirectory = $this->siteDirectory . '/temp';
- $this->translationFilesDirectory = $this->siteDirectory . '/translations';
-
- // Ensure the configImporter is refreshed for each test.
- $this->configImporter = NULL;
-
- // Unregister all custom stream wrappers of the parent site.
- $wrappers = \Drupal::service('stream_wrapper_manager')->getWrappers(StreamWrapperInterface::ALL);
- foreach ($wrappers as $scheme => $info) {
- stream_wrapper_unregister($scheme);
- }
-
- // Reset statics.
- drupal_static_reset();
-
- // Ensure there is no service container.
- $this->container = NULL;
- \Drupal::unsetContainer();
-
- // Unset globals.
- unset($GLOBALS['config_directories']);
- unset($GLOBALS['config']);
- unset($GLOBALS['conf']);
-
- // Log fatal errors.
- ini_set('log_errors', 1);
- ini_set('error_log', DRUPAL_ROOT . '/' . $this->siteDirectory . '/error.log');
-
- // Change the database prefix.
- $this->changeDatabasePrefix();
-
- // After preparing the environment and changing the database prefix, we are
- // in a valid test environment.
- drupal_valid_test_ua($this->databasePrefix);
-
- // Reset settings.
- new Settings([
- // For performance, simply use the database prefix as hash salt.
- 'hash_salt' => $this->databasePrefix,
- ]);
-
- drupal_set_time_limit($this->timeLimit);
-
- // Save and clean the shutdown callbacks array because it is static cached
- // and will be changed by the test run. Otherwise it will contain callbacks
- // from both environments and the testing environment will try to call the
- // handlers defined by the original one.
- $callbacks = &drupal_register_shutdown_function();
- $this->originalShutdownCallbacks = $callbacks;
- $callbacks = [];
- }
-