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

Routine composer update
author Chris Cannam
date Tue, 10 Jul 2018 15:07:59 +0100
parents
children
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\DrupalKernel;
Chris@16 6 use Drupal\Core\Database\Database;
Chris@16 7 use Symfony\Component\HttpFoundation\Request;
Chris@16 8
Chris@16 9 /**
Chris@16 10 * Tests installer breaks with a profile mismatch and a read-only settings.php.
Chris@16 11 *
Chris@16 12 * @group Installer
Chris@16 13 */
Chris@16 14 class InstallerExistingSettingsMismatchProfileBrokenTest extends InstallerTestBase {
Chris@16 15
Chris@16 16 /**
Chris@16 17 * {@inheritdoc}
Chris@16 18 *
Chris@16 19 * Configures a preexisting settings.php file without an install_profile
Chris@16 20 * setting before invoking the interactive installer.
Chris@16 21 */
Chris@16 22 protected function prepareEnvironment() {
Chris@16 23 parent::prepareEnvironment();
Chris@16 24 // Pre-configure hash salt.
Chris@16 25 // Any string is valid, so simply use the class name of this test.
Chris@16 26 $this->settings['settings']['hash_salt'] = (object) [
Chris@16 27 'value' => __CLASS__,
Chris@16 28 'required' => TRUE,
Chris@16 29 ];
Chris@16 30
Chris@16 31 // Pre-configure database credentials.
Chris@16 32 $connection_info = Database::getConnectionInfo();
Chris@16 33 unset($connection_info['default']['pdo']);
Chris@16 34 unset($connection_info['default']['init_commands']);
Chris@16 35
Chris@16 36 $this->settings['databases']['default'] = (object) [
Chris@16 37 'value' => $connection_info,
Chris@16 38 'required' => TRUE,
Chris@16 39 ];
Chris@16 40
Chris@16 41 // During interactive install we'll change this to a different profile and
Chris@16 42 // this test will ensure that the new value is written to settings.php.
Chris@16 43 $this->settings['settings']['install_profile'] = (object) [
Chris@16 44 'value' => 'minimal',
Chris@16 45 'required' => TRUE,
Chris@16 46 ];
Chris@16 47
Chris@16 48 // Pre-configure config directories.
Chris@16 49 $site_path = DrupalKernel::findSitePath(Request::createFromGlobals());
Chris@16 50 $this->settings['config_directories'] = [
Chris@16 51 CONFIG_SYNC_DIRECTORY => (object) [
Chris@16 52 'value' => $site_path . '/files/config_staging',
Chris@16 53 'required' => TRUE,
Chris@16 54 ],
Chris@16 55 ];
Chris@16 56 mkdir($this->settings['config_directories'][CONFIG_SYNC_DIRECTORY]->value, 0777, TRUE);
Chris@16 57 }
Chris@16 58
Chris@16 59 /**
Chris@16 60 * {@inheritdoc}
Chris@16 61 */
Chris@16 62 protected function visitInstaller() {
Chris@16 63 // Make settings file not writable. This will break the installer.
Chris@16 64 $filename = $this->siteDirectory . '/settings.php';
Chris@16 65 // Make the settings file read-only.
Chris@16 66 // Not using File API; a potential error must trigger a PHP warning.
Chris@16 67 chmod($filename, 0444);
Chris@16 68
Chris@16 69 $this->drupalGet($GLOBALS['base_url'] . '/core/install.php?langcode=en&profile=testing');
Chris@16 70 }
Chris@16 71
Chris@16 72 /**
Chris@16 73 * {@inheritdoc}
Chris@16 74 */
Chris@16 75 protected function setUpLanguage() {
Chris@16 76 // This step is skipped, because there is a lagcode as a query param.
Chris@16 77 }
Chris@16 78
Chris@16 79 /**
Chris@16 80 * {@inheritdoc}
Chris@16 81 */
Chris@16 82 protected function setUpProfile() {
Chris@16 83 // This step is skipped, because there is a profile as a query param.
Chris@16 84 }
Chris@16 85
Chris@16 86 /**
Chris@16 87 * {@inheritdoc}
Chris@16 88 */
Chris@16 89 protected function setUpSettings() {
Chris@16 90 // This step should not appear, since settings.php is fully configured
Chris@16 91 // already.
Chris@16 92 }
Chris@16 93
Chris@16 94 protected function setUpSite() {
Chris@16 95 // This step should not appear, since settings.php could not be written.
Chris@16 96 }
Chris@16 97
Chris@16 98 /**
Chris@16 99 * Verifies that installation did not succeed.
Chris@16 100 */
Chris@16 101 public function testBrokenInstaller() {
Chris@16 102 $this->assertTitle('Install profile mismatch | Drupal');
Chris@16 103 $this->assertText("The selected profile testing does not match the install_profile setting, which is minimal. Cannot write updated setting to {$this->siteDirectory}/settings.php.");
Chris@16 104 }
Chris@16 105
Chris@16 106 }