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