You are here

function simpletest_overview_form in SimpleTest 5

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

Create simpletest_overview_form

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 171

Code

function simpletest_overview_form() {
  $output = array();
  $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) {
      $test_info = $test
        ->get_info();
      $desc = $test_info['desc'];
      $group['tests'][get_class($test)] = array(
        '#type' => 'checkbox',
        '#title' => $test_info['name'],
        '#default_value' => 0,
        '#description' => $desc,
      );
    }
    $output[] = array_merge($group, array(
      '#type' => 'fieldset',
      '#collapsible' => FALSE,
      '#collapsed' => 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[] = array_merge($submit, array(
    '#type' => 'fieldset',
    '#collapsible' => FALSE,
    '#collapsed' => FALSE,
    '#title' => 'Run tests',
  ));
  return $output;
}