comparison core/tests/Drupal/FunctionalTests/Installer/InstallerExistingSettingsMismatchProfileTest.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\DrupalKernel;
6 use Drupal\Core\Site\Settings;
7 use Drupal\Core\Database\Database;
8 use Symfony\Component\HttpFoundation\Request;
9
10 /**
11 * Tests the installer with an existing settings file but no install profile.
12 *
13 * @group Installer
14 */
15 class InstallerExistingSettingsMismatchProfileTest 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 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 // Pre-configure database credentials.
33 $connection_info = Database::getConnectionInfo();
34 unset($connection_info['default']['pdo']);
35 unset($connection_info['default']['init_commands']);
36
37 $this->settings['databases']['default'] = (object) [
38 'value' => $connection_info,
39 'required' => TRUE,
40 ];
41
42 // During interactive install we'll change this to a different profile and
43 // this test will ensure that the new value is written to settings.php.
44 $this->settings['settings']['install_profile'] = (object) [
45 'value' => 'minimal',
46 'required' => TRUE,
47 ];
48
49 // Pre-configure config directories.
50 $this->settings['config_directories'] = [
51 CONFIG_SYNC_DIRECTORY => (object) [
52 'value' => DrupalKernel::findSitePath(Request::createFromGlobals()) . '/files/config_sync',
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 // Provide profile and language in query string to skip these pages.
64 $this->drupalGet($GLOBALS['base_url'] . '/core/install.php?langcode=en&profile=testing');
65 }
66
67 /**
68 * {@inheritdoc}
69 */
70 protected function setUpLanguage() {
71 // This step is skipped, because there is a lagcode as a query param.
72 }
73
74 /**
75 * {@inheritdoc}
76 */
77 protected function setUpProfile() {
78 // This step is skipped, because there is a profile as a query param.
79 }
80
81 /**
82 * {@inheritdoc}
83 */
84 protected function setUpSettings() {
85 // This step should not appear, since settings.php is fully configured
86 // already.
87 }
88
89 /**
90 * Verifies that installation succeeded.
91 */
92 public function testInstaller() {
93 $this->assertUrl('user/1');
94 $this->assertResponse(200);
95 $this->assertEqual('testing', \Drupal::installProfile());
96 $this->assertEqual('testing', Settings::get('install_profile'), 'Profile was correctly changed to testing in Settings.php');
97 }
98
99 }