3 namespace Drupal\FunctionalTests\Installer;
5 use Drupal\Core\Database\Database;
8 * Tests the installer with an existing settings file with database connection
13 class InstallerExistingDatabaseSettingsTest extends InstallerTestBase {
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']);
25 $this->settings['databases']['default'] = (object) [
26 'value' => $connection_info,
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
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'];
43 if (isset($values[$driver]['password']) && $values[$driver]['password'] !== '') {
44 $edit = $this->translatePostValues([
46 'password' => $values[$driver]['password'],
50 $this->drupalPostForm(NULL, $edit, $this->translations['Save and continue']);
54 * Verifies that installation succeeded.
56 public function testInstaller() {
57 $this->assertUrl('user/1');
58 $this->assertResponse(200);