Skip to content

Commit

Permalink
UnitTests - Tighten class-scanning for civicrm-core:tests/phpunit
Browse files Browse the repository at this point in the history
This addresses a bug where:

1. Class-scanning of `civicrm-core:tests/phpunit/*` works with core-test-suites
2. Class-scanning of `civicrm-core:tests/phpunit/*` fails with civiimport test-suite.

The difference is that core-tests setup class-loading for
`civicrm-core:tests/phpunit/`; `civimport` understandably doesn't.

Class-scanning is only viable if we regard the specific classes a loadable.

This further tightens it:

1. Since core-test-suites can load `civicrm-core:tests/phpunit/*`, they will scan it
2. Since civiimport test-suite cannot load it, it will not scan it.
  • Loading branch information
totten committed Aug 23, 2022
1 parent 2a172ce commit 4cd22a3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Civi/Core/ClassScanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,10 @@ private static function scanCoreClasses(): array {
static::scanFolders($classes, $civicrmRoot, 'Civi/WorkflowMessage', '\\');
static::scanFolders($classes, $civicrmRoot, 'CRM/*/Import', '_');
if (\CRM_Utils_Constant::value('CIVICRM_UF') === 'UnitTests') {
static::scanFolders($classes, $civicrmRoot . 'tests/phpunit', 'CRM/*/WorkflowMessage', '_');
static::scanFolders($classes, $civicrmRoot . 'tests/phpunit', 'Civi/*/WorkflowMessage', '\\');
if (strpos(get_include_path(), $civicrmRoot . 'tests/phpunit') !== FALSE) {
static::scanFolders($classes, $civicrmRoot . 'tests/phpunit', 'CRM/*/WorkflowMessage', '_');
static::scanFolders($classes, $civicrmRoot . 'tests/phpunit', 'Civi/*/WorkflowMessage', '\\');
}
}

$cache->set($cacheKey, $classes, static::TTL);
Expand Down

0 comments on commit 4cd22a3

Please sign in to comment.