Actually runs tests.
$test_list: List of tests to run.
$reporter: Which reporter to use. Allowed values are: text, xml, html and drupal, drupal being the default.
function simpletest_run_tests($test_list, $reporter = 'drupal') {
$test_id = db_insert('simpletest_test_id')
->useDefaults(array(
'test_id',
))
->execute();
$phpunit_tests = isset($test_list['UnitTest']) ? $test_list['UnitTest'] : array();
if ($phpunit_tests) {
$phpunit_results = simpletest_run_phpunit_tests($test_id, $phpunit_tests);
simpletest_process_phpunit_results($phpunit_results);
}
if (!array_key_exists('WebTest', $test_list) || empty($test_list['WebTest'])) {
// Early return if there are no WebTests to run.
return $test_id;
}
// Contine with SimpleTests only.
$test_list = $test_list['WebTest'];
// Clear out the previous verbose files.
file_unmanaged_delete_recursive('public://simpletest/verbose');
// Get the info for the first test being run.
$first_test = array_shift($test_list);
$first_instance = new $first_test();
array_unshift($test_list, $first_test);
$info = $first_instance
->getInfo();
$batch = array(
'title' => t('Running tests'),
'operations' => array(
array(
'_simpletest_batch_operation',
array(
$test_list,
$test_id,
),
),
),
'finished' => '_simpletest_batch_finished',
'progress_message' => '',
'css' => array(
drupal_get_path('module', 'simpletest') . '/css/simpletest.module.css',
),
'init_message' => t('Processing test @num of @max - %test.', array(
'%test' => $info['name'],
'@num' => '1',
'@max' => count($test_list),
)),
);
batch_set($batch);
module_invoke_all('test_group_started');
return $test_id;
}