Chris@16
|
1 <?php
|
Chris@16
|
2
|
Chris@16
|
3 namespace Drupal\FunctionalTests\Installer;
|
Chris@16
|
4
|
Chris@16
|
5 use Drupal\Core\DrupalKernel;
|
Chris@16
|
6 use Drupal\Core\Site\Settings;
|
Chris@16
|
7 use Drupal\Core\Database\Database;
|
Chris@16
|
8 use Symfony\Component\HttpFoundation\Request;
|
Chris@16
|
9
|
Chris@16
|
10 /**
|
Chris@16
|
11 * Tests the installer with an existing settings file but no install profile.
|
Chris@16
|
12 *
|
Chris@16
|
13 * @group Installer
|
Chris@16
|
14 */
|
Chris@16
|
15 class InstallerExistingSettingsMismatchProfileTest extends InstallerTestBase {
|
Chris@16
|
16
|
Chris@16
|
17 /**
|
Chris@16
|
18 * {@inheritdoc}
|
Chris@16
|
19 *
|
Chris@16
|
20 * Configures a preexisting settings.php file without an install_profile
|
Chris@16
|
21 * setting before invoking the interactive installer.
|
Chris@16
|
22 */
|
Chris@16
|
23 protected function prepareEnvironment() {
|
Chris@16
|
24 parent::prepareEnvironment();
|
Chris@16
|
25 // Pre-configure hash salt.
|
Chris@16
|
26 // Any string is valid, so simply use the class name of this test.
|
Chris@16
|
27 $this->settings['settings']['hash_salt'] = (object) [
|
Chris@16
|
28 'value' => __CLASS__,
|
Chris@16
|
29 'required' => TRUE,
|
Chris@16
|
30 ];
|
Chris@16
|
31
|
Chris@16
|
32 // Pre-configure database credentials.
|
Chris@16
|
33 $connection_info = Database::getConnectionInfo();
|
Chris@16
|
34 unset($connection_info['default']['pdo']);
|
Chris@16
|
35 unset($connection_info['default']['init_commands']);
|
Chris@16
|
36
|
Chris@16
|
37 $this->settings['databases']['default'] = (object) [
|
Chris@16
|
38 'value' => $connection_info,
|
Chris@16
|
39 'required' => TRUE,
|
Chris@16
|
40 ];
|
Chris@16
|
41
|
Chris@16
|
42 // During interactive install we'll change this to a different profile and
|
Chris@16
|
43 // this test will ensure that the new value is written to settings.php.
|
Chris@16
|
44 $this->settings['settings']['install_profile'] = (object) [
|
Chris@16
|
45 'value' => 'minimal',
|
Chris@16
|
46 'required' => TRUE,
|
Chris@16
|
47 ];
|
Chris@16
|
48
|
Chris@16
|
49 // Pre-configure config directories.
|
Chris@16
|
50 $this->settings['config_directories'] = [
|
Chris@16
|
51 CONFIG_SYNC_DIRECTORY => (object) [
|
Chris@16
|
52 'value' => DrupalKernel::findSitePath(Request::createFromGlobals()) . '/files/config_sync',
|
Chris@16
|
53 'required' => TRUE,
|
Chris@16
|
54 ],
|
Chris@16
|
55 ];
|
Chris@16
|
56 mkdir($this->settings['config_directories'][CONFIG_SYNC_DIRECTORY]->value, 0777, TRUE);
|
Chris@16
|
57 }
|
Chris@16
|
58
|
Chris@16
|
59 /**
|
Chris@16
|
60 * {@inheritdoc}
|
Chris@16
|
61 */
|
Chris@16
|
62 protected function visitInstaller() {
|
Chris@16
|
63 // Provide profile and language in query string to skip these pages.
|
Chris@16
|
64 $this->drupalGet($GLOBALS['base_url'] . '/core/install.php?langcode=en&profile=testing');
|
Chris@16
|
65 }
|
Chris@16
|
66
|
Chris@16
|
67 /**
|
Chris@16
|
68 * {@inheritdoc}
|
Chris@16
|
69 */
|
Chris@16
|
70 protected function setUpLanguage() {
|
Chris@16
|
71 // This step is skipped, because there is a lagcode as a query param.
|
Chris@16
|
72 }
|
Chris@16
|
73
|
Chris@16
|
74 /**
|
Chris@16
|
75 * {@inheritdoc}
|
Chris@16
|
76 */
|
Chris@16
|
77 protected function setUpProfile() {
|
Chris@16
|
78 // This step is skipped, because there is a profile as a query param.
|
Chris@16
|
79 }
|
Chris@16
|
80
|
Chris@16
|
81 /**
|
Chris@16
|
82 * {@inheritdoc}
|
Chris@16
|
83 */
|
Chris@16
|
84 protected function setUpSettings() {
|
Chris@16
|
85 // This step should not appear, since settings.php is fully configured
|
Chris@16
|
86 // already.
|
Chris@16
|
87 }
|
Chris@16
|
88
|
Chris@16
|
89 /**
|
Chris@16
|
90 * Verifies that installation succeeded.
|
Chris@16
|
91 */
|
Chris@16
|
92 public function testInstaller() {
|
Chris@16
|
93 $this->assertUrl('user/1');
|
Chris@16
|
94 $this->assertResponse(200);
|
Chris@16
|
95 $this->assertEqual('testing', \Drupal::installProfile());
|
Chris@16
|
96 $this->assertEqual('testing', Settings::get('install_profile'), 'Profile was correctly changed to testing in Settings.php');
|
Chris@16
|
97 }
|
Chris@16
|
98
|
Chris@16
|
99 }
|