You are here

public function TestDiscovery::findAllClassFiles in Drupal 8

Same name and namespace in other branches
  1. 9 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'.

Return value

array A classmap containing all discovered class files; i.e., a map of fully-qualified classnames to pathnames.

2 calls to TestDiscovery::findAllClassFiles()
TestDiscovery::getTestClasses in core/lib/Drupal/Core/Test/TestDiscovery.php
Discovers all available tests in all extensions.
TestDiscovery::getTestClasses in core/modules/simpletest/src/TestDiscovery.php
Discovers all available tests in all extensions.

File

core/lib/Drupal/Core/Test/TestDiscovery.php, line 227

Class

TestDiscovery
Discovers available tests.

Namespace

Drupal\Core\Test

Code

public function findAllClassFiles($extension = 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)) {
        continue;
      }
      $classmap += static::scanDirectory($namespace, $path);
    }
  }
  return $classmap;
}