function TestDiscovery::registerTestNamespaces
Same name in other branches
- 9 core/lib/Drupal/Core/Test/TestDiscovery.php \Drupal\Core\Test\TestDiscovery::registerTestNamespaces()
- 8.9.x core/lib/Drupal/Core/Test/TestDiscovery.php \Drupal\Core\Test\TestDiscovery::registerTestNamespaces()
- 10 core/lib/Drupal/Core/Test/TestDiscovery.php \Drupal\Core\Test\TestDiscovery::registerTestNamespaces()
Registers test namespaces of all extensions and core test classes.
Return value
array An associative array whose keys are PSR-4 namespace prefixes and whose values are directory names.
1 call to TestDiscovery::registerTestNamespaces()
- TestDiscovery::findAllClassFiles in core/
lib/ Drupal/ Core/ Test/ TestDiscovery.php - Discovers all class files in all available extensions.
File
-
core/
lib/ Drupal/ Core/ Test/ TestDiscovery.php, line 75
Class
- TestDiscovery
- Discovers available tests.
Namespace
Drupal\Core\TestCode
public function registerTestNamespaces() {
if (isset($this->testNamespaces)) {
return $this->testNamespaces;
}
$this->testNamespaces = [];
$existing = $this->classLoader
->getPrefixesPsr4();
// Add PHPUnit test namespaces of Drupal core. Order the namespaces by the
// test types that tend to be slowest first, to optimize overall test times
// when multiple different test types are run concurrently by the same test
// runner.
$this->testNamespaces['Drupal\\FunctionalJavascriptTests\\'] = [
$this->root . '/core/tests/Drupal/FunctionalJavascriptTests',
];
$this->testNamespaces['Drupal\\FunctionalTests\\'] = [
$this->root . '/core/tests/Drupal/FunctionalTests',
];
$this->testNamespaces['Drupal\\BuildTests\\'] = [
$this->root . '/core/tests/Drupal/BuildTests',
];
$this->testNamespaces['Drupal\\Tests\\'] = [
$this->root . '/core/tests/Drupal/Tests',
];
$this->testNamespaces['Drupal\\KernelTests\\'] = [
$this->root . '/core/tests/Drupal/KernelTests',
];
$this->testNamespaces['Drupal\\TestTools\\'] = [
$this->root . '/core/tests/Drupal/TestTools',
];
$this->availableExtensions = [];
foreach ($this->getExtensions() as $name => $extension) {
$this->availableExtensions[$extension->getType()][$name] = $name;
$base_path = $this->root . '/' . $extension->getPath();
// Add namespace of disabled/uninstalled extensions.
if (!isset($existing["Drupal\\{$name}\\"])) {
$this->classLoader
->addPsr4("Drupal\\{$name}\\", "{$base_path}/src");
}
// Add PHPUnit test namespaces.
$this->testNamespaces["Drupal\\Tests\\{$name}\\"][] = "{$base_path}/tests/src";
}
// Expose tests provided by core recipes.
$base_path = $this->root . '/core/recipes';
if (@opendir($base_path)) {
while (($recipe = readdir()) !== FALSE) {
$this->testNamespaces["Drupal\\FunctionalTests\\Recipe\\Core\\{$recipe}\\"][] = "{$base_path}/{$recipe}/tests/src/Functional";
}
closedir();
}
foreach ($this->testNamespaces as $prefix => $paths) {
$this->classLoader
->addPsr4($prefix, $paths);
}
return $this->testNamespaces;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.