annotate core/tests/Drupal/FunctionalTests/Installer/InstallerExistingSettingsTest.php @ 0:c75dbcec494b

Initial commit from drush-created site
author Chris Cannam
date Thu, 05 Jul 2018 14:24:15 +0000
parents
children a9cd425dd02b
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 namespace Drupal\FunctionalTests\Installer;
Chris@0 4
Chris@0 5 use Drupal\Core\Site\Settings;
Chris@0 6 use Drupal\Core\Database\Database;
Chris@0 7 use Drupal\Core\DrupalKernel;
Chris@0 8 use Symfony\Component\HttpFoundation\Request;
Chris@0 9
Chris@0 10 /**
Chris@0 11 * Tests the installer with an existing settings file.
Chris@0 12 *
Chris@0 13 * @group Installer
Chris@0 14 */
Chris@0 15 class InstallerExistingSettingsTest extends InstallerTestBase {
Chris@0 16
Chris@0 17 /**
Chris@0 18 * {@inheritdoc}
Chris@0 19 *
Chris@0 20 * Fully configures a preexisting settings.php file before invoking the
Chris@0 21 * interactive installer.
Chris@0 22 */
Chris@0 23 protected function prepareEnvironment() {
Chris@0 24 parent::prepareEnvironment();
Chris@0 25 // Pre-configure hash salt.
Chris@0 26 // Any string is valid, so simply use the class name of this test.
Chris@0 27 $this->settings['settings']['hash_salt'] = (object) [
Chris@0 28 'value' => __CLASS__,
Chris@0 29 'required' => TRUE,
Chris@0 30 ];
Chris@0 31
Chris@0 32 // During interactive install we'll change this to a different profile and
Chris@0 33 // this test will ensure that the new value is written to settings.php.
Chris@0 34 $this->settings['settings']['install_profile'] = (object) [
Chris@0 35 'value' => 'minimal',
Chris@0 36 'required' => TRUE,
Chris@0 37 ];
Chris@0 38
Chris@0 39 // Pre-configure database credentials.
Chris@0 40 $connection_info = Database::getConnectionInfo();
Chris@0 41 unset($connection_info['default']['pdo']);
Chris@0 42 unset($connection_info['default']['init_commands']);
Chris@0 43
Chris@0 44 $this->settings['databases']['default'] = (object) [
Chris@0 45 'value' => $connection_info,
Chris@0 46 'required' => TRUE,
Chris@0 47 ];
Chris@0 48
Chris@0 49 // Use the kernel to find the site path because the site.path service should
Chris@0 50 // not be available at this point in the install process.
Chris@0 51 $site_path = DrupalKernel::findSitePath(Request::createFromGlobals());
Chris@0 52 // Pre-configure config directories.
Chris@0 53 $this->settings['config_directories'] = [
Chris@0 54 CONFIG_SYNC_DIRECTORY => (object) [
Chris@0 55 'value' => $site_path . '/files/config_sync',
Chris@0 56 'required' => TRUE,
Chris@0 57 ],
Chris@0 58 ];
Chris@0 59 mkdir($this->settings['config_directories'][CONFIG_SYNC_DIRECTORY]->value, 0777, TRUE);
Chris@0 60 }
Chris@0 61
Chris@0 62 /**
Chris@0 63 * {@inheritdoc}
Chris@0 64 */
Chris@0 65 protected function setUpSettings() {
Chris@0 66 // This step should not appear, since settings.php is fully configured
Chris@0 67 // already.
Chris@0 68 }
Chris@0 69
Chris@0 70 /**
Chris@0 71 * Verifies that installation succeeded.
Chris@0 72 */
Chris@0 73 public function testInstaller() {
Chris@0 74 $this->assertUrl('user/1');
Chris@0 75 $this->assertResponse(200);
Chris@0 76 $this->assertEqual('testing', \Drupal::installProfile(), 'Profile was changed from minimal to testing during interactive install.');
Chris@0 77 $this->assertEqual('testing', Settings::get('install_profile'), 'Profile was correctly changed to testing in Settings.php');
Chris@0 78 }
Chris@0 79
Chris@0 80 }