You are here

function simpletest_overview_form in SimpleTest 6

Same name and namespace in other branches
  1. 5 simpletest.module \simpletest_overview_form()

Form callback; make the form to run tests

1 string reference to 'simpletest_overview_form'
simpletest_entrypoint in ./simpletest.module
Menu callback for both running tests and listing possible tests

File

./simpletest.module, line 139

Code

function simpletest_overview_form() {
  $output = array();
  $total_test =& simpletest_get_total_test();
  $test_instances = $total_test
    ->getTestInstances();
  foreach ($test_instances as $group_test) {
    $group = array();
    $tests = $group_test
      ->getTestInstances();
    $group_class = str_replace(' ', '-', strtolower($group_test
      ->getLabel()));
    $group['tests'] = array(
      '#type' => 'fieldset',
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
      '#title' => 'Tests',
      '#attributes' => array(
        'class' => $group_class,
      ),
    );
    foreach ($tests as $test) {
      if (method_exists($test, 'get_info')) {
        $test_info = $test
          ->get_info();
        $desc = $test_info['desc'];
      }
      elseif (method_exists($test, 'getInfo')) {
        $test_info = $test
          ->getInfo();
        $desc = $test_info['description'];
      }
      $group['tests'][get_class($test)] = array(
        '#type' => 'checkbox',
        '#title' => $test_info['name'],
        '#default_value' => 0,
        '#description' => $desc,
      );
    }
    $output[] = $group + array(
      '#type' => 'fieldset',
      '#collapsible' => FALSE,
      '#title' => $group_test
        ->getLabel(),
      '#attributes' => array(
        'class' => 'select_all',
      ),
    );
  }
  $submit['running_options'] = array(
    '#type' => 'radios',
    '#default_value' => 'selected_tests',
    '#options' => array(
      'all_tests' => t('Run all tests (WARNING, this may take a long time)'),
      'selected_tests' => t('Run selected tests'),
    ),
  );
  $submit['op'] = array(
    '#type' => 'submit',
    '#value' => t('Begin'),
  );
  $output[] = $submit + array(
    '#type' => 'fieldset',
    '#collapsible' => FALSE,
    '#collapsed' => FALSE,
    '#title' => 'Run tests',
  );
  $output['reset'] = array(
    '#type' => 'fieldset',
    '#collapsible' => FALSE,
    '#collapsed' => FALSE,
    '#title' => 'Clean Environment',
    '#description' => 'Remove tables with the prefix "simpletest" and temporary directories that are left over from tests that crashed.',
  );
  $output['reset']['op'] = array(
    '#type' => 'submit',
    '#value' => t('Clean Environment'),
    '#submit' => array(
      'simpletest_clean_environment',
    ),
  );
  return $output;
}