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