Mercurial > hg > isophonics-drupal-site
comparison core/tests/Drupal/FunctionalTests/Installer/InstallerExistingSettingsTest.php @ 16:c2387f117808
Routine composer update
author | Chris Cannam |
---|---|
date | Tue, 10 Jul 2018 15:07:59 +0100 |
parents | |
children | 129ea1e6d783 |
comparison
equal
deleted
inserted
replaced
15:e200cb7efeb3 | 16:c2387f117808 |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\FunctionalTests\Installer; | |
4 | |
5 use Drupal\Core\Site\Settings; | |
6 use Drupal\Core\Database\Database; | |
7 use Drupal\Core\DrupalKernel; | |
8 use Symfony\Component\HttpFoundation\Request; | |
9 | |
10 /** | |
11 * Tests the installer with an existing settings file. | |
12 * | |
13 * @group Installer | |
14 */ | |
15 class InstallerExistingSettingsTest extends InstallerTestBase { | |
16 | |
17 /** | |
18 * {@inheritdoc} | |
19 * | |
20 * Fully configures a preexisting settings.php file before invoking the | |
21 * interactive installer. | |
22 */ | |
23 protected function prepareEnvironment() { | |
24 parent::prepareEnvironment(); | |
25 // Pre-configure hash salt. | |
26 // Any string is valid, so simply use the class name of this test. | |
27 $this->settings['settings']['hash_salt'] = (object) [ | |
28 'value' => __CLASS__, | |
29 'required' => TRUE, | |
30 ]; | |
31 | |
32 // During interactive install we'll change this to a different profile and | |
33 // this test will ensure that the new value is written to settings.php. | |
34 $this->settings['settings']['install_profile'] = (object) [ | |
35 'value' => 'minimal', | |
36 'required' => TRUE, | |
37 ]; | |
38 | |
39 // Pre-configure database credentials. | |
40 $connection_info = Database::getConnectionInfo(); | |
41 unset($connection_info['default']['pdo']); | |
42 unset($connection_info['default']['init_commands']); | |
43 | |
44 $this->settings['databases']['default'] = (object) [ | |
45 'value' => $connection_info, | |
46 'required' => TRUE, | |
47 ]; | |
48 | |
49 // Use the kernel to find the site path because the site.path service should | |
50 // not be available at this point in the install process. | |
51 $site_path = DrupalKernel::findSitePath(Request::createFromGlobals()); | |
52 // Pre-configure config directories. | |
53 $this->settings['config_directories'] = [ | |
54 CONFIG_SYNC_DIRECTORY => (object) [ | |
55 'value' => $site_path . '/files/config_sync', | |
56 'required' => TRUE, | |
57 ], | |
58 ]; | |
59 mkdir($this->settings['config_directories'][CONFIG_SYNC_DIRECTORY]->value, 0777, TRUE); | |
60 } | |
61 | |
62 /** | |
63 * {@inheritdoc} | |
64 */ | |
65 protected function setUpSettings() { | |
66 // This step should not appear, since settings.php is fully configured | |
67 // already. | |
68 } | |
69 | |
70 /** | |
71 * Verifies that installation succeeded. | |
72 */ | |
73 public function testInstaller() { | |
74 $this->assertUrl('user/1'); | |
75 $this->assertResponse(200); | |
76 $this->assertEqual('testing', \Drupal::installProfile(), 'Profile was changed from minimal to testing during interactive install.'); | |
77 $this->assertEqual('testing', Settings::get('install_profile'), 'Profile was correctly changed to testing in Settings.php'); | |
78 } | |
79 | |
80 } |