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

simpletest_registry_files_alter()

File

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

Code

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();
      foreach ($files as $file) {
        $classes = backdrop_parse_info_file($file->uri, TRUE);
        foreach ($classes as $class => $info) {
          $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;
        }
      }

      // 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;
}