Download & Extend

Module tests with extending submodule tests not included correctly.

Project:SimpleTest
Version:6.x-2.x-dev
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

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

<?php
class MyModuleTestHelper extends DrupalWebTestCase {
  function
assertBlah() {
    ...
  }
?>

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

<?php
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.

<?php
  $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:

<?php
  $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.

Comments

#1

Status:active» needs review
AttachmentSizeStatusTest resultOperations
577324-subtests.patch863 bytesIgnored: Check issue status.NoneNone

#2

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.

#3

Status:fixed» closed (fixed)

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