Mercurial > hg > isophonics-drupal-site
comparison core/modules/system/src/Tests/Installer/InstallerExistingSettingsMismatchProfileBrokenTest.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\system\Tests\Installer; | |
4 | |
5 use Drupal\Core\DrupalKernel; | |
6 use Drupal\simpletest\InstallerTestBase; | |
7 use Drupal\Core\Database\Database; | |
8 use Symfony\Component\HttpFoundation\Request; | |
9 | |
10 /** | |
11 * Tests installer breaks with a profile mismatch and a read-only settings.php. | |
12 * | |
13 * @group Installer | |
14 */ | |
15 class InstallerExistingSettingsMismatchProfileBrokenTest extends InstallerTestBase { | |
16 | |
17 /** | |
18 * {@inheritdoc} | |
19 * | |
20 * Configures a preexisting settings.php file without an install_profile | |
21 * setting before invoking the interactive installer. | |
22 */ | |
23 protected function setUp() { | |
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 parent::setUp(); | |
59 } | |
60 | |
61 /** | |
62 * {@inheritdoc} | |
63 */ | |
64 protected function visitInstaller() { | |
65 // Make settings file not writable. This will break the installer. | |
66 $filename = $this->siteDirectory . '/settings.php'; | |
67 // Make the settings file read-only. | |
68 // Not using File API; a potential error must trigger a PHP warning. | |
69 chmod($filename, 0444); | |
70 | |
71 $this->drupalGet($GLOBALS['base_url'] . '/core/install.php?langcode=en&profile=testing'); | |
72 } | |
73 | |
74 /** | |
75 * {@inheritdoc} | |
76 */ | |
77 protected function setUpLanguage() { | |
78 // This step is skipped, because there is a lagcode as a query param. | |
79 } | |
80 | |
81 /** | |
82 * {@inheritdoc} | |
83 */ | |
84 protected function setUpProfile() { | |
85 // This step is skipped, because there is a profile as a query param. | |
86 } | |
87 | |
88 /** | |
89 * {@inheritdoc} | |
90 */ | |
91 protected function setUpSettings() { | |
92 // This step should not appear, since settings.php is fully configured | |
93 // already. | |
94 } | |
95 | |
96 protected function setUpSite() { | |
97 // This step should not appear, since settings.php could not be written. | |
98 } | |
99 | |
100 /** | |
101 * Verifies that installation did not succeed. | |
102 */ | |
103 public function testBrokenInstaller() { | |
104 $this->assertTitle('Install profile mismatch | Drupal'); | |
105 $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."); | |
106 } | |
107 | |
108 } |