3 namespace Drupal\system\Tests\Installer;
5 use Drupal\Core\DrupalKernel;
6 use Drupal\Core\Site\Settings;
7 use Drupal\simpletest\InstallerTestBase;
8 use Drupal\Core\Database\Database;
9 use Symfony\Component\HttpFoundation\Request;
12 * Tests the installer with an existing settings file but no install profile.
16 class InstallerExistingSettingsMismatchProfileTest extends InstallerTestBase {
21 * Configures a preexisting settings.php file without an install_profile
22 * setting before invoking the 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 // Pre-configure database credentials.
33 $connection_info = Database::getConnectionInfo();
34 unset($connection_info['default']['pdo']);
35 unset($connection_info['default']['init_commands']);
37 $this->settings['databases']['default'] = (object) [
38 'value' => $connection_info,
42 // During interactive install we'll change this to a different profile and
43 // this test will ensure that the new value is written to settings.php.
44 $this->settings['settings']['install_profile'] = (object) [
49 // Pre-configure config directories.
50 $this->settings['config_directories'] = [
51 CONFIG_SYNC_DIRECTORY => (object) [
52 'value' => DrupalKernel::findSitePath(Request::createFromGlobals()) . '/files/config_sync',
56 mkdir($this->settings['config_directories'][CONFIG_SYNC_DIRECTORY]->value, 0777, TRUE);
64 protected function visitInstaller() {
65 // Provide profile and language in query string to skip these pages.
66 $this->drupalGet($GLOBALS['base_url'] . '/core/install.php?langcode=en&profile=testing');
72 protected function setUpLanguage() {
73 // This step is skipped, because there is a lagcode as a query param.
79 protected function setUpProfile() {
80 // This step is skipped, because there is a profile as a query param.
86 protected function setUpSettings() {
87 // This step should not appear, since settings.php is fully configured
92 * Verifies that installation succeeded.
94 public function testInstaller() {
95 $this->assertUrl('user/1');
96 $this->assertResponse(200);
97 $this->assertEqual('testing', \Drupal::installProfile());
98 $this->assertEqual('testing', Settings::get('install_profile'), 'Profile was correctly changed to testing in Settings.php');