3 namespace Drupal\FunctionalTests\Installer;
5 use Drupal\Core\DrupalKernel;
6 use Drupal\Core\Site\Settings;
7 use Drupal\Core\Database\Database;
8 use Symfony\Component\HttpFoundation\Request;
11 * Tests install with existing settings.php and a mismatching 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 prepareEnvironment() {
25 parent::prepareEnvironment();
26 // Pre-configure hash salt.
27 // Any string is valid, so simply use the class name of this test.
28 $this->settings['settings']['hash_salt'] = (object) [
33 // Pre-configure database credentials.
34 $connection_info = Database::getConnectionInfo();
35 unset($connection_info['default']['pdo']);
36 unset($connection_info['default']['init_commands']);
38 $this->settings['databases']['default'] = (object) [
39 'value' => $connection_info,
43 // During interactive install we'll change this to a different profile and
44 // this test will ensure that the new value is written to settings.php.
45 $this->settings['settings']['install_profile'] = (object) [
50 // Pre-configure config directories.
51 $this->settings['config_directories'] = [
52 CONFIG_SYNC_DIRECTORY => (object) [
53 'value' => DrupalKernel::findSitePath(Request::createFromGlobals()) . '/files/config_sync',
57 mkdir($this->settings['config_directories'][CONFIG_SYNC_DIRECTORY]->value, 0777, TRUE);
63 protected function visitInstaller() {
64 // Provide profile and language in query string to skip these pages.
65 $this->drupalGet($GLOBALS['base_url'] . '/core/install.php?langcode=en&profile=testing');
71 protected function setUpLanguage() {
72 // This step is skipped, because there is a langcode as a query param.
78 protected function setUpProfile() {
79 // This step is skipped, because there is a profile as a query param.
85 protected function setUpSettings() {
86 // This step should not appear, since settings.php is fully configured
91 * Verifies that installation succeeded.
93 * @expectedDeprecation To access the install profile in Drupal 8 use \Drupal::installProfile() or inject the install_profile container parameter into your service. See https://www.drupal.org/node/2538996
95 public function testInstaller() {
96 $this->assertUrl('user/1');
97 $this->assertResponse(200);
98 $this->assertEqual('testing', \Drupal::installProfile());
99 $this->assertEqual('testing', Settings::get('install_profile'), 'Profile was correctly changed to testing in Settings.php');