3 namespace Drupal\system\Tests\Installer;
5 use Drupal\Core\Site\Settings;
6 use Drupal\simpletest\InstallerTestBase;
7 use Drupal\Core\Database\Database;
8 use Drupal\Core\DrupalKernel;
9 use Symfony\Component\HttpFoundation\Request;
12 * Tests the installer with an existing settings file.
16 class InstallerExistingSettingsTest extends InstallerTestBase {
21 * Fully configures a preexisting settings.php file before invoking the
22 * interactive installer.
24 protected function setUp() {
25 // Pre-configure hash salt.
26 // Any string is valid, so simply use the class name of this test.
27 $this->settings['settings']['hash_salt'] = (object) [
32 // During interactive install we'll change this to a different profile and
33 // this test will ensure that the new value is written to settings.php.
34 $this->settings['settings']['install_profile'] = (object) [
39 // Pre-configure database credentials.
40 $connection_info = Database::getConnectionInfo();
41 unset($connection_info['default']['pdo']);
42 unset($connection_info['default']['init_commands']);
44 $this->settings['databases']['default'] = (object) [
45 'value' => $connection_info,
49 // Use the kernel to find the site path because the site.path service should
50 // not be available at this point in the install process.
51 $site_path = DrupalKernel::findSitePath(Request::createFromGlobals());
52 // Pre-configure config directories.
53 $this->settings['config_directories'] = [
54 CONFIG_SYNC_DIRECTORY => (object) [
55 'value' => $site_path . '/files/config_sync',
59 mkdir($this->settings['config_directories'][CONFIG_SYNC_DIRECTORY]->value, 0777, TRUE);
67 protected function setUpSettings() {
68 // This step should not appear, since settings.php is fully configured
73 * Verifies that installation succeeded.
75 public function testInstaller() {
76 $this->assertUrl('user/1');
77 $this->assertResponse(200);
78 $this->assertEqual('testing', \Drupal::installProfile(), 'Profile was changed from minimal to testing during interactive install.');
79 $this->assertEqual('testing', Settings::get('install_profile'), 'Profile was correctly changed to testing in Settings.php');