function TestDiscovery::findAllClassFiles

Same name in other branches
  1. 9 core/lib/Drupal/Core/Test/TestDiscovery.php \Drupal\Core\Test\TestDiscovery::findAllClassFiles()
  2. 10 core/lib/Drupal/Core/Test/TestDiscovery.php \Drupal\Core\Test\TestDiscovery::findAllClassFiles()
  3. 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'.

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/modules/simpletest/src/TestDiscovery.php
Discovers all available tests in all extensions.
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 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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.