Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / tests / Drupal / FunctionalTests / Installer / InstallerExistingDatabaseSettingsTest.php
1 <?php
2
3 namespace Drupal\FunctionalTests\Installer;
4
5 use Drupal\Core\Database\Database;
6
7 /**
8  * Tests the installer with an existing settings file with database connection
9  * info.
10  *
11  * @group Installer
12  */
13 class InstallerExistingDatabaseSettingsTest extends InstallerTestBase {
14
15   /**
16    * {@inheritdoc}
17    */
18   protected function prepareEnvironment() {
19     parent::prepareEnvironment();
20     // Pre-configure database credentials in settings.php.
21     $connection_info = Database::getConnectionInfo();
22     unset($connection_info['default']['pdo']);
23     unset($connection_info['default']['init_commands']);
24
25     $this->settings['databases']['default'] = (object) [
26       'value' => $connection_info,
27       'required' => TRUE,
28     ];
29   }
30
31   /**
32    * {@inheritdoc}
33    *
34    * @todo The database settings form is not supposed to appear if settings.php
35    *   contains a valid database connection already (but e.g. no config
36    *   directories yet).
37    */
38   protected function setUpSettings() {
39     // All database settings should be pre-configured, except password.
40     $values = $this->parameters['forms']['install_settings_form'];
41     $driver = $values['driver'];
42     $edit = [];
43     if (isset($values[$driver]['password']) && $values[$driver]['password'] !== '') {
44       $edit = $this->translatePostValues([
45         $driver => [
46           'password' => $values[$driver]['password'],
47         ],
48       ]);
49     }
50     $this->drupalPostForm(NULL, $edit, $this->translations['Save and continue']);
51   }
52
53   /**
54    * Verifies that installation succeeded.
55    */
56   public function testInstaller() {
57     $this->assertUrl('user/1');
58     $this->assertResponse(200);
59   }
60
61 }