diff options
author | Dries Buytaert <dries@buytaert.net> | 2009-10-08 15:18:27 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2009-10-08 15:18:27 +0000 |
commit | ca709290cc6e8345a358f44636928fc4db86db6b (patch) | |
tree | 85d0516706b65a0f195f81e1477979ff7b28a633 /modules/simpletest/simpletest.module | |
parent | f06ed4f6707b40b2eaa16523a8f777418c1db547 (diff) | |
download | brdo-ca709290cc6e8345a358f44636928fc4db86db6b.tar.gz brdo-ca709290cc6e8345a358f44636928fc4db86db6b.tar.bz2 |
- Patch #343502 by Dave Reid, sun | dbabbage, Dries, boombatower: allow tests to require and test existence of modules. Required to make testing contributed modules possible.
Diffstat (limited to 'modules/simpletest/simpletest.module')
-rw-r--r-- | modules/simpletest/simpletest.module | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/modules/simpletest/simpletest.module b/modules/simpletest/simpletest.module index 84ce85e71..234ecb89d 100644 --- a/modules/simpletest/simpletest.module +++ b/modules/simpletest/simpletest.module @@ -334,29 +334,30 @@ function simpletest_test_get_all() { } else { // Select all clases in files ending with .test. - $classes = db_select('registry') - ->fields('registry', array('name')) - ->condition('type', 'class') - ->condition('filename', '%.test', 'LIKE') - ->execute(); - - $groups = array(); + $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')) { - // Valid test class, retrieve test information. $info = call_user_func(array($class, 'getInfo')); - // Initialize test groups. - if (!isset($groups[$info['group']])) { - $groups[$info['group']] = array(); + // 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) { |