function SimpletestResultsForm::submitForm

Overrides FormInterface::submitForm

File

core/modules/simpletest/src/Form/SimpletestResultsForm.php, line 184

Class

SimpletestResultsForm
Test results form for $test_id.

Namespace

Drupal\simpletest\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
    $pass = $form_state->getValue('filter_pass') ? explode(',', $form_state->getValue('filter_pass')) : [];
    $fail = $form_state->getValue('filter_fail') ? explode(',', $form_state->getValue('filter_fail')) : [];
    if ($form_state->getValue('filter') == 'all') {
        $classes = array_merge($pass, $fail);
    }
    elseif ($form_state->getValue('filter') == 'pass') {
        $classes = $pass;
    }
    else {
        $classes = $fail;
    }
    if (!$classes) {
        $form_state->setRedirect('simpletest.test_form');
        return;
    }
    $form_execute = [];
    $form_state_execute = new FormState();
    foreach ($classes as $class) {
        $form_state_execute->setValue([
            'tests',
            $class,
        ], $class);
    }
    // Submit the simpletest test form to rerun the tests.
    // Under normal circumstances, a form object's submitForm() should never be
    // called directly, FormBuilder::submitForm() should be called instead.
    // However, it calls $form_state->setProgrammed(), which disables the Batch API.
    $simpletest_test_form = SimpletestTestForm::create(\Drupal::getContainer());
    $simpletest_test_form->buildForm($form_execute, $form_state_execute);
    $simpletest_test_form->submitForm($form_execute, $form_state_execute);
    if ($redirect = $form_state_execute->getRedirect()) {
        $form_state->setRedirectUrl($redirect);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.