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