1 simpletest.module | simpletest_run_tests($test_list, $reporter = 'backdrop') |
Actually runs tests.
Parameters
$test_list: List of tests to run.
$reporter: Which reporter to use. Allowed values are: text, xml, html and backdrop, backdrop being the default.
File
- core/
modules/ simpletest/ simpletest.module, line 145 - Provides testing functionality.
Code
function simpletest_run_tests($test_list, $reporter = 'backdrop') {
$test_id = db_query("SELECT MAX(test_id) FROM {simpletest_prefix}")->fetchField() + 1;
// Clear out the previous verbose files.
if (file_exists('public://simpletest/verbose')) {
file_unmanaged_delete_recursive('public://simpletest/verbose');
}
$cache = config_get('simpletest.settings', 'simpletest_cache');
if ($cache) {
$profiles = simpletest_get_profiles();
foreach ($profiles as $profile) {
try {
$test_cache = new BackdropWebTestCaseCache();
$test_cache->setProfile($profile->name);
if (!$test_cache->isCached()) {
$test_cache->prepareCache(TRUE);
}
}
catch (Exception $e) {
watchdog_exception('simpletest', $e, $e->getMessage());
}
}
}
// Get the info for the first test being run.
$first_test = array_shift($test_list);
$test_info = simpletest_test_get_by_class($first_test);
include_once BACKDROP_ROOT . '/' . $test_info['file path'] . '/' . $test_info['file'];
$first_instance = new $first_test();
array_unshift($test_list, $first_test);
$info = simpletest_test_get_by_class(get_class($first_instance));
$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(backdrop_get_path('module', 'simpletest') . '/css/simpletest.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;
}