diff -u b/core/modules/simpletest/simpletest.module b/core/modules/simpletest/simpletest.module --- b/core/modules/simpletest/simpletest.module +++ b/core/modules/simpletest/simpletest.module @@ -419,6 +419,9 @@ * each module for files matching the PSR-0 standard. Once loaded the test list * is cached and stored in a static variable. * + * @param string $module + * Name of a module. If set then only tests belonging to this module is + * returned. * @return * 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 @@ -435,16 +438,19 @@ * @endcode */ function simpletest_test_get_all($module = NULL) { - $groups = &drupal_static(__FUNCTION__); + $all_groups = &drupal_static(__FUNCTION__); + $cid = "simpletest:$module"; - if (!$groups) { + if (!isset($all_groups[$cid])) { + $all_groups[$cid] = array(); + $groups = &$all_groups[$cid]; // Make sure that namespaces for disabled modules are registered so that the // checks below will find them. simpletest_classloader_register(); // Load test information from cache if available, otherwise retrieve the // information from each tests getInfo() method. - if ($cache = cache()->get('simpletest')) { + if ($cache = cache()->get($cid)) { $groups = $cache->data; } else { @@ -453,6 +459,7 @@ $module_data = system_rebuild_module_data(); $all_data = $module_data + system_rebuild_theme_data(); $all_data += drupal_system_listing('/\.profile$/', 'profiles', 'name'); + // If module is set then we keep only that one module. if (isset($module)) { $all_data = array( $module => $all_data[$module], @@ -504,8 +511,8 @@ } // If this test class requires a non-existing module, skip it. if (!empty($info['dependencies'])) { - foreach ($info['dependencies'] as $module) { - if (!isset($module_data[$module])) { + foreach ($info['dependencies'] as $dependency) { + if (!isset($dependency_data[$dependency])) { continue 2; } } @@ -523,10 +530,10 @@ // Allow modules extending core tests to disable originals. drupal_alter('simpletest', $groups); - cache()->set('simpletest', $groups); + cache()->set($cid, $groups); } } - return $groups; + return $all_groups[$cid]; } /** @@ -729,8 +736,9 @@ /** * Get PHPUnit Classes * - * @param bool $name_only - * If TRUE, returns a flat array of class names only. + * @param string $module + * Name of a module. If set then only tests belonging to this module is + * returned. */ function simpletest_phpunit_get_available_tests($module = NULL) { // Try to load the class names array from cache.