Index: simpletest.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/simpletest/simpletest.module,v retrieving revision 1.33.2.1 diff -u -b -u -p -r1.33.2.1 simpletest.module --- simpletest.module 26 Feb 2008 19:16:21 -0000 1.33.2.1 +++ simpletest.module 18 Apr 2008 23:58:39 -0000 @@ -33,6 +33,20 @@ function simpletest_menu() { 'page arguments' => array('simpletest_settings'), 'access arguments' => array('access administration pages'), ); + $items['admin/reports/simpletest'] = array( + 'title' => 'SimpleTest overview', + 'description' => 'Overview of the available SimpleTest test against Drupal core and your active modules.', + 'page callback' => 'simpletest_test_overview', + 'access arguments' => array('administer unit tests'), + 'type' => MENU_NORMAL_ITEM, + ); + $items['admin/reports/simpletest/run'] = array( + 'title' => 'SimpleTest report', + 'description' => 'Run tests against Drupal core and you active modules.', + 'page callback' => 'simpletest_run', + 'access arguments' => array('administer unit tests'), + 'type' => MENU_CALLBACK, + ); return $items; } @@ -320,3 +334,62 @@ function simpletest_trigger_error($type) } return false; } + + + +/** + * Page callback for generating a list of all available SimpleTest test + * with url's to callbacks that run these tests + */ +function simpletest_test_overview() { + // load the required simple test includes + $output = ''; + if (!simpletest_load()) { + return $output; + } + + $items = array(); + $test_suite = new DrupalUnitTests(); + // iterate over the test groups in the test suite + foreach ($test_suite->getTestInstances() as $test_group) { + $group_name = $test_group->getLabel(); + + $group_test_classes = array(); + // iterate over the test classes in the test group + foreach ($test_group->getTestInstances() as $test) { + $test_info = $test->get_info(); + $test_name = $test_info['name']; + $test_desc = $test_info['desc']; + $test_class = get_class($test); + $group_test_classes[] = $test_class; + // add test class to group list + $items[$group_name]['children'][] = t('!testurl: @descr', array( + '!testurl' => l($test_name, 'admin/reports/simpletest/run/' . $test_class, array('attributes' => array('title' => check_plain($test_class)))), + '@descr' => $test_desc, + )); + } + // add test group to list + $items[$group_name]['data'] = t('@group_name (run all):', array( + '@group_name' => $group_name, + '!testurl' => url('admin/reports/simpletest/run/' . join(',', $group_test_classes)) + )); + } + + // render as item list + $output .= theme('item_list', $items); + + return $output; +} + +/** + * Page callback for running the SimpleTest tests + */ +function simpletest_run($test_classes=NULL) { + $output = ''; + if (!$test_classes) { + drupal_set_message(t('No tests requested.')); + return $output; + } + $test_classes = explode(',', $test_classes); + return simpletest_run_tests($test_classes); +}