Say we have the following things:
/sites/all/modules/mymodule/mymodule.test:

class MyModuleTestHelper extends DrupalWebTestCase {
  function assertBlah() {
    ...
  }

/sites/all/modules/mymodule/mysubmodule/mysubmodule.test:

class MySubModuleTest extends MyModuleTestHelper {
  function setUp() {
    ...
  }
  
  function testFoo() {
    $this->assertBlah(...);
  }
}

Before this would work without problem. On the latest DRUPAL-6--2 CVS code, it causes a PHP fatal error with a class does not exist on the test selection page.

The problem is that when scanning for tests in simpletest_test_get_all_classes() the file_scan_directory is resursive and finds the submodule test files first and includes them before the base module's test files.

  $files = module_rebuild_cache();
  foreach ($files as $file) {
    $directory = dirname($file->filename);
    $test_files = file_scan_directory($directory, '\.test$');

We should restrict this to searching for any .test files of the current module directory or any test files in a subfolder of the current module called 'tests' as per the standards:

  $files = module_rebuild_cache();
  foreach ($files as $file) {
    $directory = dirname($file->filename);
    $test_files = file_scan_directory($directory, '\.test$', array('.', '..', 'CVS'), FALSE, FALSE);
    $test_files += file_scan_directory($directory . '/tests', '\.test$')

This allows the test selection screen to work, although there are other bugs so I can't check if the tests actually run.

CommentFileSizeAuthor
#1 577324-subtests.patch863 bytesdave reid

Comments

dave reid’s picture

Status: Active » Needs review
StatusFileSize
new863 bytes
boombatower’s picture

Status: Needs review » Fixed

Yea, this is not an issue with the class registry in D7, but the code for D6 it makes sense.

This doesn't seem to break anything and if it fixes your problem then I am happy to commit.

Committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.