public function SimpletestTestForm::submitForm

Form submission handler.

Parameters

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

array $form_state: An associative array containing the current state of the form.

Overrides FormInterface::submitForm

File

drupal/core/modules/simpletest/lib/Drupal/simpletest/Form/SimpletestTestForm.php, line 85
Contains \Drupal\simpletest\Form\SimpletestTestForm.

Class

SimpletestTestForm
List tests arranged in groups that can be selected and run.

Namespace

Drupal\simpletest\Form

Code

public function submitForm(array &$form, array &$form_state) {

  // Get list of tests.
  $tests_list = array();
  simpletest_classloader_register();
  $phpunit_all = array_keys($form_state['storage']['PHPUnit']);
  foreach ($form_state['values'] as $class_name => $value) {

    // Since class_exists() will likely trigger an autoload lookup,
    // we do the fast check first.
    if ($value === 1 && class_exists($class_name)) {
      $test_type = in_array($class_name, $phpunit_all) ? 'UnitTest' : 'WebTest';
      $tests_list[$test_type][] = $class_name;
    }
  }
  if (count($tests_list) > 0) {
    $test_id = simpletest_run_tests($tests_list, 'drupal');
    $form_state['redirect'] = 'admin/config/development/testing/results/' . $test_id;
  }
  else {
    drupal_set_message(t('No test(s) selected.'), 'error');
  }
}