/** * Overrides WebTestBase::setUp() for upgrade testing. * * The main difference in this method is that rather than performing the * installation via the installer, a database is loaded. Additional work is * then needed to set various things such as the config directories and the * container that would normally be done via the installer. */ protected function setUp() { // We are going to set a missing zlib requirement property for usage // during the performUpgrade() and tearDown() methods. Also set that the // tests failed. if (!$this->zlibInstalled) { parent::setUp(); return; } // These methods are called from parent::setUp(). $this->setBatch(); $this->initUserSession(); $this->prepareSettings(); // Load the database(s). foreach ($this->databaseDumpFiles as $file) { if (substr($file, -3) == '.gz') { $file = "compress.zlib://{$file}"; } require $file; } $this->initSettings(); $request = Request::createFromGlobals(); $container = $this->initKernel($request); $this->initConfig($container); // Add the config directories to settings.php. drupal_install_config_directories(); // Install any additional modules. $this->installModulesFromClassProperty($container); // Restore the original Simpletest batch. $this->restoreBatch(); // Rebuild and reset. $this->rebuildAll(); // Replace User 1 with the user created here. /** @var \Drupal\user\UserInterface $account */ $account = User::load(1); $account->setPassword($this->rootUser->pass_raw); $account->setEmail($this->rootUser->getEmail()); $account->setUsername($this->rootUser->getUsername()); $account->save(); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { global $install_state; // Update global settings array and save. $settings = array(); $database = $form_state->get('database'); $settings['databases']['default']['default'] = (object) array('value' => $database, 'required' => TRUE); $settings['settings']['hash_salt'] = (object) array('value' => Crypt::randomBytesBase64(55), 'required' => TRUE); // Remember the profile which was used. $settings['settings']['install_profile'] = (object) array('value' => $install_state['parameters']['profile'], 'required' => TRUE); drupal_rewrite_settings($settings); // Add the config directories to settings.php. drupal_install_config_directories(); // Indicate that the settings file has been verified, and check the database // for the last completed task, now that we have a valid connection. This // last step is important since we want to trigger an error if the new // database already has Drupal installed. $install_state['settings_verified'] = TRUE; $install_state['config_verified'] = TRUE; $install_state['database_verified'] = TRUE; $install_state['completed_task'] = install_verify_completed_task(); }
/** * Overrides WebTestBase::setUp() for update testing. * * The main difference in this method is that rather than performing the * installation via the installer, a database is loaded. Additional work is * then needed to set various things such as the config directories and the * container that would normally be done via the installer. */ protected function setUp() { $this->runDbTasks(); // Allow classes to set database dump files. $this->setDatabaseDumpFiles(); // We are going to set a missing zlib requirement property for usage // during the performUpgrade() and tearDown() methods. Also set that the // tests failed. if (!$this->zlibInstalled) { parent::setUp(); return; } // Set the update url. This must be set here rather than in // self::__construct() or the old URL generator will leak additional test // sites. $this->updateUrl = Url::fromRoute('system.db_update'); // These methods are called from parent::setUp(). $this->setBatch(); $this->initUserSession(); $this->prepareSettings(); // Load the database(s). foreach ($this->databaseDumpFiles as $file) { if (substr($file, -3) == '.gz') { $file = "compress.zlib://{$file}"; } require $file; } $this->initSettings(); $request = Request::createFromGlobals(); $container = $this->initKernel($request); $this->initConfig($container); // Add the config directories to settings.php. drupal_install_config_directories(); // Restore the original Simpletest batch. $this->restoreBatch(); // Set the container. parent::rebuildAll() would normally do this, but this // not safe to do here, because the database has not been updated yet. $this->container = \Drupal::getContainer(); $this->replaceUser1(); }