Mercurial > hg > isophonics-drupal-site
comparison core/tests/Drupal/FunctionalTests/Installer/InstallerExistingSettingsReadOnlyMismatchProfileTest.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\FunctionalTests\Installer; | |
4 | |
5 use Drupal\Core\DrupalKernel; | |
6 use Drupal\Core\Database\Database; | |
7 use Drupal\Core\Site\Settings; | |
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 * @group legacy | |
15 */ | |
16 class InstallerExistingSettingsReadOnlyMismatchProfileTest extends InstallerTestBase { | |
17 | |
18 /** | |
19 * {@inheritdoc} | |
20 * | |
21 * Configures a preexisting settings.php file without an install_profile | |
22 * setting before invoking the interactive installer. | |
23 */ | |
24 protected function prepareEnvironment() { | |
25 parent::prepareEnvironment(); | |
26 // Pre-configure hash salt. | |
27 // Any string is valid, so simply use the class name of this test. | |
28 $this->settings['settings']['hash_salt'] = (object) [ | |
29 'value' => __CLASS__, | |
30 'required' => TRUE, | |
31 ]; | |
32 | |
33 // Pre-configure database credentials. | |
34 $connection_info = Database::getConnectionInfo(); | |
35 unset($connection_info['default']['pdo']); | |
36 unset($connection_info['default']['init_commands']); | |
37 | |
38 $this->settings['databases']['default'] = (object) [ | |
39 'value' => $connection_info, | |
40 'required' => TRUE, | |
41 ]; | |
42 | |
43 // During interactive install we'll change this to a different profile and | |
44 // this test will ensure that the new value is written to settings.php. | |
45 $this->settings['settings']['install_profile'] = (object) [ | |
46 'value' => 'minimal', | |
47 'required' => TRUE, | |
48 ]; | |
49 | |
50 // Pre-configure config directories. | |
51 $site_path = DrupalKernel::findSitePath(Request::createFromGlobals()); | |
52 $this->settings['config_directories'] = [ | |
53 CONFIG_SYNC_DIRECTORY => (object) [ | |
54 'value' => $site_path . '/files/config_staging', | |
55 'required' => TRUE, | |
56 ], | |
57 ]; | |
58 mkdir($this->settings['config_directories'][CONFIG_SYNC_DIRECTORY]->value, 0777, TRUE); | |
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 /** | |
97 * Verifies that installation succeeded. | |
98 * | |
99 * @expectedDeprecation To access the install profile in Drupal 8 use \Drupal::installProfile() or inject the install_profile container parameter into your service. See https://www.drupal.org/node/2538996 | |
100 */ | |
101 public function testInstalled() { | |
102 $this->initBrowserOutputFile(); | |
103 $this->htmlOutput(NULL); | |
104 $this->assertEquals('testing', \Drupal::installProfile()); | |
105 $this->assertEquals('minimal', Settings::get('install_profile')); | |
106 $this->drupalGet('admin/reports/status'); | |
107 $this->assertSession()->pageTextContains("Drupal 8 no longer uses the \$settings['install_profile'] value in settings.php and it can be removed."); | |
108 } | |
109 | |
110 } |