diff --git a/core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php b/core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php index 0f1f25bb914d0c24f89e22317b69413a9165c154..739d6177414cb35105b86b58d11516402054a3a2 100644 --- a/core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php +++ b/core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php @@ -67,6 +67,8 @@ public function getFormId() { * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { + // Make sure the install API is available. + include_once DRUPAL_ROOT . '/core/includes/install.inc'; $settings_file = './' . $this->sitePath . '/settings.php'; $form['#title'] = $this->t('Database configuration'); @@ -155,6 +157,9 @@ public function buildForm(array $form, FormStateInterface $form_state) { * {@inheritdoc} */ public function validateForm(array &$form, FormStateInterface $form_state) { + // Make sure the install API is available. + include_once DRUPAL_ROOT . '/core/includes/install.inc'; + $driver = $form_state->getValue('driver'); $database = $form_state->getValue($driver); $drivers = drupal_get_database_types(); @@ -236,6 +241,9 @@ public static function getDatabaseErrorsTemplate(array $errors) { public function submitForm(array &$form, FormStateInterface $form_state) { global $install_state; + // Make sure the install API is available. + include_once DRUPAL_ROOT . '/core/includes/install.inc'; + // Update global settings array and save. $settings = []; $database = $form_state->get('database'); diff --git a/core/modules/system/tests/modules/install_form_test/install_form_test.info.yml b/core/modules/system/tests/modules/install_form_test/install_form_test.info.yml new file mode 100644 index 0000000000000000000000000000000000000000..fb0457d495d4a301be34521d26c9c99398bcc465 --- /dev/null +++ b/core/modules/system/tests/modules/install_form_test/install_form_test.info.yml @@ -0,0 +1,5 @@ +name: Install Form Test +type: module +description: Test the SiteSettingsForm can be extended. +package: Testing +version: VERSION diff --git a/core/modules/system/tests/modules/install_form_test/install_form_test.routing.yml b/core/modules/system/tests/modules/install_form_test/install_form_test.routing.yml new file mode 100644 index 0000000000000000000000000000000000000000..9d5ec44479ee9e0d5174ac9fc87d5e55dc4d461a --- /dev/null +++ b/core/modules/system/tests/modules/install_form_test/install_form_test.routing.yml @@ -0,0 +1,7 @@ +install_form_test.test-form: + path: /test-form + defaults: + _form: \Drupal\install_form_test\Form\ExtendedForm + _title: Extended Site Settings Form + requirements: + _access: 'TRUE' diff --git a/core/modules/system/tests/modules/install_form_test/src/Form/ExtendedForm.php b/core/modules/system/tests/modules/install_form_test/src/Form/ExtendedForm.php new file mode 100644 index 0000000000000000000000000000000000000000..613519ead3cd44e579a6cab44ae7718ca25e06e2 --- /dev/null +++ b/core/modules/system/tests/modules/install_form_test/src/Form/ExtendedForm.php @@ -0,0 +1,11 @@ +<?php + +namespace Drupal\install_form_test\Form; + +use Drupal\Core\Installer\Form\SiteSettingsForm; + +/** + * Extends the site setting form. + */ +class ExtendedForm extends SiteSettingsForm { +} diff --git a/core/tests/Drupal/FunctionalTests/Installer/SiteSettingsFormTest.php b/core/tests/Drupal/FunctionalTests/Installer/SiteSettingsFormTest.php new file mode 100644 index 0000000000000000000000000000000000000000..58fd60ab8194741e642da3c177f5069c7e16ec8c --- /dev/null +++ b/core/tests/Drupal/FunctionalTests/Installer/SiteSettingsFormTest.php @@ -0,0 +1,33 @@ +<?php + +namespace Drupal\FunctionalTests\Installer; + +use Drupal\Tests\BrowserTestBase; + +/** + * Tests the extension of the site settings form. + * + * @group Installer + */ +class SiteSettingsFormTest extends BrowserTestBase { + + /** + * {@inheritdoc} + */ + protected static $modules = ['install_form_test']; + + /** + * {@inheritdoc} + */ + protected $defaultTheme = 'stark'; + + /** + * Confirms that the form is extensible. + */ + public function testSiteSettingsForm() { + // Test that the form page can be loaded without errors. + $this->drupalGet('test-form'); + $this->assertSession()->statusCodeEquals(200); + } + +}