function simpletest_run_tests
Same name in other branches
- 7.x modules/simpletest/simpletest.module \simpletest_run_tests()
Runs tests.
Parameters
array[] $test_list: List of tests to run. The top level is keyed by type of test, either 'simpletest' or 'phpunit'. Under that is an array of class names to run.
Return value
string The test ID.
2 calls to simpletest_run_tests()
- SimpletestTestForm::submitForm in core/
modules/ simpletest/ src/ Form/ SimpletestTestForm.php - Form submission handler.
- TestDeprecatedTestHooks::testHookTestGroupStarted in core/
modules/ simpletest/ tests/ src/ Kernel/ TestDeprecatedTestHooks.php - @expectedDeprecation The deprecated hook hook_test_group_started() is implemented in these functions: simpletest_deprecation_test_test_group_started(). Convert your test to a PHPUnit-based one and implement test listeners. Seeā¦
File
-
core/
modules/ simpletest/ simpletest.module, line 133
Code
function simpletest_run_tests($test_list) {
// We used to separate PHPUnit and Simpletest tests for a performance
// optimization. In order to support backwards compatibility check if these
// keys are set and create a single test list.
// @todo https://www.drupal.org/node/2748967 Remove BC support in Drupal 9.
if (isset($test_list['simpletest'])) {
$test_list = array_merge($test_list, $test_list['simpletest']);
unset($test_list['simpletest']);
}
if (isset($test_list['phpunit'])) {
$test_list = array_merge($test_list, $test_list['phpunit']);
unset($test_list['phpunit']);
}
$test_id = \Drupal::database()->insert('simpletest_test_id')
->useDefaults([
'test_id',
])
->execute();
// Clear out the previous verbose files.
try {
\Drupal::service('file_system')->deleteRecursive('public://simpletest/verbose');
} catch (FileException $e) {
// Ignore failed deletes.
}
// Get the info for the first test being run.
$first_test = reset($test_list);
$info = TestDiscovery::getTestInfo($first_test);
$batch = [
'title' => t('Running tests'),
'operations' => [
[
'_simpletest_batch_operation',
[
$test_list,
$test_id,
],
],
],
'finished' => '_simpletest_batch_finished',
'progress_message' => '',
'library' => [
'simpletest/drupal.simpletest',
],
'init_message' => t('Processing test @num of @max - %test.', [
'%test' => $info['name'],
'@num' => '1',
'@max' => count($test_list),
]),
];
batch_set($batch);
\Drupal::moduleHandler()->invokeAllDeprecated('Convert your test to a PHPUnit-based one and implement test listeners. See https://www.drupal.org/node/2934242', 'test_group_started');
return $test_id;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.