1 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 by each owning module's: .tests.info file and then keyed by the test class. An example of the array structure is provided below.

    $groups['Block'] => array(
      'BlockTestCase' => array(
        'name' => 'Block functionality',
        'description' => 'Add, edit and delete custom block...',
        'group' => 'Block',
        'file' => block.test,
        'file path' => 'core/modules/block',

See also



core/modules/simpletest/simpletest.module, line 356
Provides testing functionality.


function simpletest_test_get_all() {
  $groups = &backdrop_static(__FUNCTION__);

  if (!$groups) {
    // Load test information from cache if available, otherwise retrieve the
    // information from each module's *.tests.info file.
    if ($cache = cache()->get('simpletest')) {
      $groups = $cache->data;
    else {
      $files = backdrop_system_listing('/^' . BACKDROP_PHP_FUNCTION_PATTERN . '\.tests\.info$/', 'modules', 'name', 0);
      $groups = array();
      $check_keys = array('name', 'description', 'group', 'file');
      foreach ($files as $file) {
        $classes = backdrop_parse_info_file($file->uri, TRUE);
        $error = '';
        if (empty($classes)) {
          $error = 'File %uri contains no testing classes.';
        else {
          foreach ($classes as $class => $info) {
            // If the .tests.info file is malformed, it puts a slew of
            // hard-to-diagnose errors into the watchdog log when the testing page
            // is loaded. So we'll check for various malformalities and put a more
            // informative error.
            if (!is_array($info) || empty($info)) {
              $error = format_string('File %uri contains a definition for %class that is not an array of testing class fields.', array('%class' => $class));
            else {
              $missing_keys = array();
              foreach ($check_keys as $key) {
                if (!isset($info[$key])) {
                  $missing_keys[] = $key;
              if (!empty($missing_keys)) {
                $keys = implode(', ', $missing_keys);
                $error = format_plural(count($missing_keys), 'File %uri contains a definition for %class that is missing field %keys.', 'File %uri contains a definition for %class that is missing fields %keys.', array('%class' => $class, '%keys' => $keys));
            if (empty($error)) {
              // If the format passed, build the rest of the groups information.
              $info['file path'] = dirname($file->uri);
              // If this test class requires a non-existing module, skip it.
              if (!empty($info['dependencies'])) {
                foreach ($info['dependencies'] as $module) {
                  if (!backdrop_get_filename('module', $module)) {
                    continue 2;
              $groups[$info['group']][$class] = $info;
        if (!empty($error)) {
          watchdog('simpletest', $error, array('%uri' => $file->uri), WATCHDOG_WARNING, l(t('See the Testing Framework documentation.'), 'https://docs.backdropcms.org/documentation/testing-framework'));

      // Sort the groups and tests within the groups by name.
      uksort($groups, 'strnatcasecmp');
      foreach ($groups as &$tests) {
        uksort($tests, 'strnatcasecmp');

      // Allow modules extending core tests to disable originals.
      backdrop_alter('simpletest', $groups);
      cache()->set('simpletest', $groups);
  return $groups;