simpletest_monitor.module

Tracking 7.x-2.x branch
  1. drupal
    1. 7 contributions/simpletest/monitor/simpletest_monitor.module

Ensure that 2.x style tests are removed when core API is being used.

Functions & methods

NameDescription
simpletest_monitor_registry_files_alterImplement hook_registry_files_alter().

File

View source
  1. <?php
  2. /**
  3. * @file
  4. * Ensure that 2.x style tests are removed when core API is being used.
  5. */
  6. /**
  7. * Implement hook_registry_files_alter().
  8. */
  9. function simpletest_monitor_registry_files_alter(&$files, $modules) {
  10. // Determine what the active SimpleTest API version currently is.
  11. $api = FALSE;
  12. foreach ($modules as $module) {
  13. if ($module->name == 'simpletest') {
  14. $api = substr($module->dir, 0, 7) == 'modules' ? 1 : 2;
  15. break;
  16. }
  17. }
  18. if ($api == 1) {
  19. // Remove 2.x compatible test files.
  20. foreach ($modules as $module) {
  21. if (!empty($module->info['files'])) {
  22. if (!empty($module->info['testing_api']) && $module->info['testing_api'] == '2.x') {
  23. $dir = $module->dir;
  24. foreach ($module->info['files'] as $file) {
  25. if (substr($file, -5) == '.test') {
  26. unset($files["$dir/$file"]);
  27. }
  28. }
  29. }
  30. }
  31. }
  32. }
  33. }