Chris@16
|
1 <?php
|
Chris@16
|
2
|
Chris@16
|
3 namespace Drupal\FunctionalTests\Installer;
|
Chris@16
|
4
|
Chris@16
|
5 use Drupal\Core\Database\Database;
|
Chris@16
|
6 use Drupal\Core\DrupalKernel;
|
Chris@16
|
7 use Symfony\Component\HttpFoundation\Request;
|
Chris@16
|
8
|
Chris@16
|
9 /**
|
Chris@16
|
10 * Tests the installer with an existing settings file.
|
Chris@16
|
11 *
|
Chris@16
|
12 * @group Installer
|
Chris@16
|
13 */
|
Chris@16
|
14 class InstallerExistingSettingsTest extends InstallerTestBase {
|
Chris@16
|
15
|
Chris@16
|
16 /**
|
Chris@16
|
17 * {@inheritdoc}
|
Chris@16
|
18 *
|
Chris@16
|
19 * Fully configures a preexisting settings.php file before invoking the
|
Chris@16
|
20 * interactive installer.
|
Chris@16
|
21 */
|
Chris@16
|
22 protected function prepareEnvironment() {
|
Chris@16
|
23 parent::prepareEnvironment();
|
Chris@16
|
24 // Pre-configure hash salt.
|
Chris@16
|
25 // Any string is valid, so simply use the class name of this test.
|
Chris@16
|
26 $this->settings['settings']['hash_salt'] = (object) [
|
Chris@16
|
27 'value' => __CLASS__,
|
Chris@16
|
28 'required' => TRUE,
|
Chris@16
|
29 ];
|
Chris@16
|
30
|
Chris@16
|
31 // Pre-configure database credentials.
|
Chris@16
|
32 $connection_info = Database::getConnectionInfo();
|
Chris@16
|
33 unset($connection_info['default']['pdo']);
|
Chris@16
|
34 unset($connection_info['default']['init_commands']);
|
Chris@16
|
35
|
Chris@16
|
36 $this->settings['databases']['default'] = (object) [
|
Chris@16
|
37 'value' => $connection_info,
|
Chris@16
|
38 'required' => TRUE,
|
Chris@16
|
39 ];
|
Chris@16
|
40
|
Chris@16
|
41 // Use the kernel to find the site path because the site.path service should
|
Chris@16
|
42 // not be available at this point in the install process.
|
Chris@16
|
43 $site_path = DrupalKernel::findSitePath(Request::createFromGlobals());
|
Chris@16
|
44 // Pre-configure config directories.
|
Chris@16
|
45 $this->settings['config_directories'] = [
|
Chris@16
|
46 CONFIG_SYNC_DIRECTORY => (object) [
|
Chris@16
|
47 'value' => $site_path . '/files/config_sync',
|
Chris@16
|
48 'required' => TRUE,
|
Chris@16
|
49 ],
|
Chris@16
|
50 ];
|
Chris@16
|
51 mkdir($this->settings['config_directories'][CONFIG_SYNC_DIRECTORY]->value, 0777, TRUE);
|
Chris@16
|
52 }
|
Chris@16
|
53
|
Chris@16
|
54 /**
|
Chris@16
|
55 * {@inheritdoc}
|
Chris@16
|
56 */
|
Chris@16
|
57 protected function setUpSettings() {
|
Chris@16
|
58 // This step should not appear, since settings.php is fully configured
|
Chris@16
|
59 // already.
|
Chris@16
|
60 }
|
Chris@16
|
61
|
Chris@16
|
62 /**
|
Chris@16
|
63 * Verifies that installation succeeded.
|
Chris@16
|
64 */
|
Chris@16
|
65 public function testInstaller() {
|
Chris@16
|
66 $this->assertUrl('user/1');
|
Chris@16
|
67 $this->assertResponse(200);
|
Chris@17
|
68 $this->assertEqual('testing', \Drupal::installProfile());
|
Chris@16
|
69 }
|
Chris@16
|
70
|
Chris@16
|
71 }
|