Commit b431efaf authored by webchick's avatar webchick

Issue #2212947 by sun, pwolanin, dmitry_bezer | ianthomas_uk: Installer...

Issue #2212947 by sun, pwolanin, dmitry_bezer | ianthomas_uk: Installer doesn't pick up database port or table prefix from settings.php.
parent cda25039
......@@ -87,7 +87,9 @@ protected function connect() {
*/
public function getFormOptions(array $database) {
$form = parent::getFormOptions($database);
$form['advanced_options']['port']['#default_value'] = '3306';
if (empty($form['advanced_options']['port']['#default_value'])) {
$form['advanced_options']['port']['#default_value'] = '3306';
}
return $form;
}
......
......@@ -253,8 +253,9 @@ function initializeDatabase() {
*/
public function getFormOptions(array $database) {
$form = parent::getFormOptions($database);
$form['advanced_options']['port']['#default_value'] = '5432';
if (empty($form['advanced_options']['port']['#default_value'])) {
$form['advanced_options']['port']['#default_value'] = '5432';
}
return $form;
}
}
......@@ -255,7 +255,7 @@ public function getFormOptions(array $database) {
$form['advanced_options']['prefix'] = array(
'#type' => 'textfield',
'#title' => t('Table name prefix'),
'#default_value' => '',
'#default_value' => empty($database['prefix']) ? '' : $database['prefix'],
'#size' => 45,
'#description' => t('If more than one application will be sharing this database, a unique table name prefix–such as %prefix–will prevent collisions.', array('%prefix' => $db_prefix)),
'#weight' => 10,
......
......@@ -83,7 +83,7 @@ protected function setUp() {
if (!empty($this->settings)) {
// Not using File API; a potential error must trigger a PHP warning.
copy(DRUPAL_ROOT . '/sites/default/default.settings.php', DRUPAL_ROOT . '/' . $this->siteDirectory . '/settings.php');
$this->writeSettings($settings);
$this->writeSettings($this->settings);
}
// Note that WebTestBase::installParameters() returns form input values
......
......@@ -174,6 +174,11 @@ abstract class WebTestBase extends TestBase {
*/
protected $kernel;
/**
* The config directories used in this test.
*/
protected $configDirectories = array();
/**
* Cookies to set on curl requests.
*
......
<?php
/**
* @file
* Contains \Drupal\system\Tests\Installer\InstallerEmptySettingsTest.
*/
namespace Drupal\system\Tests\Installer;
use Drupal\simpletest\InstallerTestBase;
use Drupal\Core\Database\Database;
/**
* Tests the installer to make sure existing values in settings.php appear.
*/
class InstallerExistingSettingsTest extends InstallerTestBase {
/**
* {@inheritdoc}
*/
public static function getInfo() {
return array(
'name' => 'Installer Existing Settings Test',
'description' => 'Tests the installer with an existing settings file with database connection info.',
'group' => 'Installer',
);
}
/**
* {@inheritdoc}
*/
protected function setUp() {
// Pre-configure database credentials in settings.php.
$connection_info = Database::getConnectionInfo();
unset($connection_info['default']['pdo']);
unset($connection_info['default']['init_commands']);
$this->settings['databases']['default'] = (object) array(
'value' => $connection_info,
'required' => TRUE,
);
parent::setUp();
}
/**
* {@inheritdoc}
*
* @todo The database settings form is not supposed to appear if settings.php
* contains a valid database connection already (but e.g. no config
* directories yet).
*/
protected function setUpSettings() {
// All database settings should be pre-configured, except password.
$values = $this->parameters['forms']['install_settings_form'];
$driver = $values['driver'];
$edit = array();
if (isset($values[$driver]['password']) && $values[$driver]['password'] !== '') {
$edit = $this->translatePostValues(array(
$driver => array(
'password' => $values[$driver]['password'],
),
));
}
$this->drupalPostForm(NULL, $edit, $this->translations['Save and continue']);
}
/**
* Verifies that installation succeeded.
*/
public function testInstaller() {
$this->assertUrl('user/1');
$this->assertResponse(200);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment