You are here

public function SimpletestSettingsForm::buildForm in Drupal 8

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides ConfigFormBase::buildForm

File

core/modules/simpletest/src/Form/SimpletestSettingsForm.php, line 32

Class

SimpletestSettingsForm
Configure simpletest settings for this site.

Namespace

Drupal\simpletest\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('simpletest.settings');
  $form['general'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('General'),
    '#open' => TRUE,
  ];
  $form['general']['simpletest_clear_results'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Clear results after each complete test suite run'),
    '#description' => $this
      ->t('By default SimpleTest will clear the results after they have been viewed on the results page, but in some cases it may be useful to leave the results in the database. The results can then be viewed at <em>admin/config/development/testing/results/[test_id]</em>. The test ID can be found in the database, simpletest table, or kept track of when viewing the results the first time. Additionally, some modules may provide more analysis or features that require this setting to be disabled.'),
    '#default_value' => $config
      ->get('clear_results'),
  ];
  $form['general']['simpletest_verbose'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Provide verbose information when running tests'),
    '#description' => $this
      ->t('The verbose data will be printed along with the standard assertions and is useful for debugging. The verbose data will be erased between each test suite run. The verbose data output is very detailed and should only be used when debugging.'),
    '#default_value' => $config
      ->get('verbose'),
  ];
  $form['httpauth'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('HTTP authentication'),
    '#description' => $this
      ->t('HTTP auth settings to be used by the SimpleTest browser during testing. Useful when the site requires basic HTTP authentication.'),
  ];
  $form['httpauth']['simpletest_httpauth_method'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Method'),
    '#options' => [
      CURLAUTH_BASIC => $this
        ->t('Basic'),
      CURLAUTH_DIGEST => $this
        ->t('Digest'),
      CURLAUTH_GSSNEGOTIATE => $this
        ->t('GSS negotiate'),
      CURLAUTH_NTLM => $this
        ->t('NTLM'),
      CURLAUTH_ANY => $this
        ->t('Any'),
      CURLAUTH_ANYSAFE => $this
        ->t('Any safe'),
    ],
    '#default_value' => $config
      ->get('httpauth.method'),
  ];
  $username = $config
    ->get('httpauth.username');
  $password = $config
    ->get('httpauth.password');
  $form['httpauth']['simpletest_httpauth_username'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Username'),
    '#default_value' => $username,
  ];
  if (!empty($username) && !empty($password)) {
    $form['httpauth']['simpletest_httpauth_username']['#description'] = $this
      ->t('Leave this blank to delete both the existing username and password.');
  }
  $form['httpauth']['simpletest_httpauth_password'] = [
    '#type' => 'password',
    '#title' => $this
      ->t('Password'),
  ];
  if ($password) {
    $form['httpauth']['simpletest_httpauth_password']['#description'] = $this
      ->t('To change the password, enter the new password here.');
  }
  return parent::buildForm($form, $form_state);
}