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