Mercurial > hg > cmmr2012-drupal-site
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingSettingsTest.php Thu Jul 05 14:24:15 2018 +0000 @@ -0,0 +1,80 @@ +<?php + +namespace Drupal\FunctionalTests\Installer; + +use Drupal\Core\Site\Settings; +use Drupal\Core\Database\Database; +use Drupal\Core\DrupalKernel; +use Symfony\Component\HttpFoundation\Request; + +/** + * Tests the installer with an existing settings file. + * + * @group Installer + */ +class InstallerExistingSettingsTest extends InstallerTestBase { + + /** + * {@inheritdoc} + * + * Fully configures a preexisting settings.php file before invoking the + * interactive installer. + */ + protected function prepareEnvironment() { + parent::prepareEnvironment(); + // Pre-configure hash salt. + // Any string is valid, so simply use the class name of this test. + $this->settings['settings']['hash_salt'] = (object) [ + 'value' => __CLASS__, + 'required' => TRUE, + ]; + + // During interactive install we'll change this to a different profile and + // this test will ensure that the new value is written to settings.php. + $this->settings['settings']['install_profile'] = (object) [ + 'value' => 'minimal', + 'required' => TRUE, + ]; + + // Pre-configure database credentials. + $connection_info = Database::getConnectionInfo(); + unset($connection_info['default']['pdo']); + unset($connection_info['default']['init_commands']); + + $this->settings['databases']['default'] = (object) [ + 'value' => $connection_info, + 'required' => TRUE, + ]; + + // Use the kernel to find the site path because the site.path service should + // not be available at this point in the install process. + $site_path = DrupalKernel::findSitePath(Request::createFromGlobals()); + // Pre-configure config directories. + $this->settings['config_directories'] = [ + CONFIG_SYNC_DIRECTORY => (object) [ + 'value' => $site_path . '/files/config_sync', + 'required' => TRUE, + ], + ]; + mkdir($this->settings['config_directories'][CONFIG_SYNC_DIRECTORY]->value, 0777, TRUE); + } + + /** + * {@inheritdoc} + */ + protected function setUpSettings() { + // This step should not appear, since settings.php is fully configured + // already. + } + + /** + * Verifies that installation succeeded. + */ + public function testInstaller() { + $this->assertUrl('user/1'); + $this->assertResponse(200); + $this->assertEqual('testing', \Drupal::installProfile(), 'Profile was changed from minimal to testing during interactive install.'); + $this->assertEqual('testing', Settings::get('install_profile'), 'Profile was correctly changed to testing in Settings.php'); + } + +}