function simpletest_test_get_all in SimpleTest 7
Same name and namespace in other branches
- 8.3 simpletest.module \simpletest_test_get_all()
- 6.2 simpletest.module \simpletest_test_get_all()
- 7.2 simpletest.module \simpletest_test_get_all()
Get a list of all of the tests provided by the system.
The list of test classes is loaded from the registry where it looks for files ending in ".test". Once loaded the test list is cached and stored in a static variable. In order to list tests provided by disabled modules hook_registry_files_alter() is used to forcefully add them to the registry.
Return value
An array of tests keyed with the groups specified in each of the tests getInfo() method and then keyed by the test class. An example of the array structure is provided below.
$groups['Blog'] => array(
'BlogTestCase' => array(
'name' => 'Blog functionality',
'description' => 'Create, view, edit, delete, ...',
'group' => 'Blog',
),
);
See also
simpletest_registry_files_alter()
1 call to simpletest_test_get_all()
- simpletest_test_form in ./
simpletest.pages.inc - List tests arranged in groups that can be selected and run.
File
- ./
simpletest.module, line 325 - Provides testing functionality.
Code
function simpletest_test_get_all() {
$groups =& drupal_static(__FUNCTION__);
if (!$groups) {
// Load test information from cache if available, otherwise retrieve the
// information from each tests getInfo() method.
if ($cache = cache_get('simpletest', 'cache')) {
$groups = $cache->data;
}
else {
// Select all clases in files ending with .test.
$classes = db_query("SELECT name FROM {registry} WHERE type = :type AND filename LIKE :name", array(
':type' => 'class',
':name' => '%.test',
));
// Check that each class has a getInfo() method and store the information
// in an array keyed with the group specified in the test information.
$groups = array();
foreach ($classes as $class) {
$class = $class->name;
// Test classes need to implement getInfo() to be valid.
if (class_exists($class) && method_exists($class, 'getInfo')) {
$info = call_user_func(array(
$class,
'getInfo',
));
// If this test class requires a non-existing module, skip it.
if (!empty($info['dependencies'])) {
foreach ($info['dependencies'] as $module) {
if (!drupal_get_filename('module', $module)) {
continue 2;
}
}
}
$groups[$info['group']][$class] = $info;
}
}
// Sort the groups and tests within the groups by name.
uksort($groups, 'strnatcasecmp');
foreach ($groups as $group => &$tests) {
uksort($tests, 'strnatcasecmp');
}
cache_set('simpletest', $groups);
}
}
return $groups;
}