3 namespace Drupal\FunctionalTests\Installer;
5 use Drupal\Core\Database\Database;
6 use Drupal\Core\DrupalKernel;
7 use Symfony\Component\HttpFoundation\Request;
10 * Tests the installer with an existing settings file.
14 class InstallerExistingSettingsTest extends InstallerTestBase {
19 * Fully configures a preexisting settings.php file before invoking the
20 * interactive installer.
22 protected function prepareEnvironment() {
23 parent::prepareEnvironment();
24 // Pre-configure hash salt.
25 // Any string is valid, so simply use the class name of this test.
26 $this->settings['settings']['hash_salt'] = (object) [
31 // Pre-configure database credentials.
32 $connection_info = Database::getConnectionInfo();
33 unset($connection_info['default']['pdo']);
34 unset($connection_info['default']['init_commands']);
36 $this->settings['databases']['default'] = (object) [
37 'value' => $connection_info,
41 // Use the kernel to find the site path because the site.path service should
42 // not be available at this point in the install process.
43 $site_path = DrupalKernel::findSitePath(Request::createFromGlobals());
44 // Pre-configure config directories.
45 $this->settings['config_directories'] = [
46 CONFIG_SYNC_DIRECTORY => (object) [
47 'value' => $site_path . '/files/config_sync',
51 mkdir($this->settings['config_directories'][CONFIG_SYNC_DIRECTORY]->value, 0777, TRUE);
57 protected function setUpSettings() {
58 // This step should not appear, since settings.php is fully configured
63 * Verifies that installation succeeded.
65 public function testInstaller() {
66 $this->assertUrl('user/1');
67 $this->assertResponse(200);
68 $this->assertEqual('testing', \Drupal::installProfile());