Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 namespace Drupal\system\Tests\Installer;
|
Chris@0
|
4
|
Chris@0
|
5 use Drupal\Core\Site\Settings;
|
Chris@0
|
6 use Drupal\simpletest\InstallerTestBase;
|
Chris@0
|
7 use Drupal\Core\Database\Database;
|
Chris@0
|
8 use Drupal\Core\DrupalKernel;
|
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.
|
Chris@0
|
13 *
|
Chris@0
|
14 * @group Installer
|
Chris@0
|
15 */
|
Chris@0
|
16 class InstallerExistingSettingsTest extends InstallerTestBase {
|
Chris@0
|
17
|
Chris@0
|
18 /**
|
Chris@0
|
19 * {@inheritdoc}
|
Chris@0
|
20 *
|
Chris@0
|
21 * Fully configures a preexisting settings.php file before invoking the
|
Chris@0
|
22 * 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 // During interactive install we'll change this to a different profile and
|
Chris@0
|
33 // this test will ensure that the new value is written to settings.php.
|
Chris@0
|
34 $this->settings['settings']['install_profile'] = (object) [
|
Chris@0
|
35 'value' => 'minimal',
|
Chris@0
|
36 'required' => TRUE,
|
Chris@0
|
37 ];
|
Chris@0
|
38
|
Chris@0
|
39 // Pre-configure database credentials.
|
Chris@0
|
40 $connection_info = Database::getConnectionInfo();
|
Chris@0
|
41 unset($connection_info['default']['pdo']);
|
Chris@0
|
42 unset($connection_info['default']['init_commands']);
|
Chris@0
|
43
|
Chris@0
|
44 $this->settings['databases']['default'] = (object) [
|
Chris@0
|
45 'value' => $connection_info,
|
Chris@0
|
46 'required' => TRUE,
|
Chris@0
|
47 ];
|
Chris@0
|
48
|
Chris@0
|
49 // Use the kernel to find the site path because the site.path service should
|
Chris@0
|
50 // not be available at this point in the install process.
|
Chris@0
|
51 $site_path = DrupalKernel::findSitePath(Request::createFromGlobals());
|
Chris@0
|
52 // Pre-configure config directories.
|
Chris@0
|
53 $this->settings['config_directories'] = [
|
Chris@0
|
54 CONFIG_SYNC_DIRECTORY => (object) [
|
Chris@0
|
55 'value' => $site_path . '/files/config_sync',
|
Chris@0
|
56 'required' => TRUE,
|
Chris@0
|
57 ],
|
Chris@0
|
58 ];
|
Chris@0
|
59 mkdir($this->settings['config_directories'][CONFIG_SYNC_DIRECTORY]->value, 0777, TRUE);
|
Chris@0
|
60
|
Chris@0
|
61 parent::setUp();
|
Chris@0
|
62 }
|
Chris@0
|
63
|
Chris@0
|
64 /**
|
Chris@0
|
65 * {@inheritdoc}
|
Chris@0
|
66 */
|
Chris@0
|
67 protected function setUpSettings() {
|
Chris@0
|
68 // This step should not appear, since settings.php is fully configured
|
Chris@0
|
69 // already.
|
Chris@0
|
70 }
|
Chris@0
|
71
|
Chris@0
|
72 /**
|
Chris@0
|
73 * Verifies that installation succeeded.
|
Chris@0
|
74 */
|
Chris@0
|
75 public function testInstaller() {
|
Chris@0
|
76 $this->assertUrl('user/1');
|
Chris@0
|
77 $this->assertResponse(200);
|
Chris@0
|
78 $this->assertEqual('testing', \Drupal::installProfile(), 'Profile was changed from minimal to testing during interactive install.');
|
Chris@0
|
79 $this->assertEqual('testing', Settings::get('install_profile'), 'Profile was correctly changed to testing in Settings.php');
|
Chris@0
|
80 }
|
Chris@0
|
81
|
Chris@0
|
82 }
|