function TestDiscovery::findAllClassFiles
Same name in other branches
- 9 core/lib/Drupal/Core/Test/TestDiscovery.php \Drupal\Core\Test\TestDiscovery::findAllClassFiles()
- 8.9.x core/lib/Drupal/Core/Test/TestDiscovery.php \Drupal\Core\Test\TestDiscovery::findAllClassFiles()
- 11.x core/lib/Drupal/Core/Test/TestDiscovery.php \Drupal\Core\Test\TestDiscovery::findAllClassFiles()
Discovers all class files in all available extensions.
Parameters
string $extension: (optional) The name of an extension to limit discovery to; e.g., 'node'.
string|null $directory: (optional) Limit discovered tests to a specific directory.
Return value
array A classmap containing all discovered class files; i.e., a map of fully-qualified classnames to path names.
1 call to TestDiscovery::findAllClassFiles()
- TestDiscovery::getTestClasses in core/
lib/ Drupal/ Core/ Test/ TestDiscovery.php - Discovers all available tests in all extensions.
File
-
core/
lib/ Drupal/ Core/ Test/ TestDiscovery.php, line 216
Class
- TestDiscovery
- Discovers available tests.
Namespace
Drupal\Core\TestCode
public function findAllClassFiles($extension = NULL, ?string $directory = NULL) {
$classmap = [];
$namespaces = $this->registerTestNamespaces();
if (isset($extension)) {
// Include tests in the \Drupal\Tests\{$extension} namespace.
$pattern = "/Drupal\\\\(Tests\\\\)?{$extension}\\\\/";
$namespaces = array_intersect_key($namespaces, array_flip(preg_grep($pattern, array_keys($namespaces))));
}
foreach ($namespaces as $namespace => $paths) {
foreach ($paths as $path) {
if (!is_dir($path) || !is_null($directory) && !str_contains($path, $directory)) {
continue;
}
$classmap += static::scanDirectory($namespace, $path);
}
}
return $classmap;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.