annotate core/tests/Drupal/FunctionalTests/Installer/InstallerExistingSettingsTest.php @ 16:c2387f117808

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