Commit a56ce007 authored by catch's avatar catch
Browse files

Issue #2272011 by mashermike, quietone, mikeryan, rpayanm: SiteSettingsForm...

Issue #2272011 by mashermike, quietone, mikeryan, rpayanm: SiteSettingsForm needs to include install.inc
parent f386b0bb
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -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');
+5 −0
Original line number Diff line number Diff line
name: Install Form Test
type: module
description: Test the SiteSettingsForm can be extended.
package: Testing
version: VERSION
+7 −0
Original line number Diff line number Diff line
install_form_test.test-form:
  path: /test-form
  defaults:
    _form: \Drupal\install_form_test\Form\ExtendedForm
    _title: Extended Site Settings Form
  requirements:
    _access: 'TRUE'
+11 −0
Original line number Diff line number Diff line
<?php

namespace Drupal\install_form_test\Form;

use Drupal\Core\Installer\Form\SiteSettingsForm;

/**
 * Extends the site setting form.
 */
class ExtendedForm extends SiteSettingsForm {
}
+33 −0
Original line number Diff line number Diff line
<?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);
  }

}