function drupal_phpunit_get_extension_namespaces

Same name in other branches
  1. 9 core/tests/bootstrap.php \drupal_phpunit_get_extension_namespaces()
  2. 8.9.x core/tests/bootstrap.php \drupal_phpunit_get_extension_namespaces()
  3. 11.x core/tests/bootstrap.php \drupal_phpunit_get_extension_namespaces()

Registers the namespace for each extension directory with the autoloader.

Parameters

array $dirs: An associative array of extension directories, keyed by extension name.

Return value

array An associative array of extension directories, keyed by their namespace.

1 call to drupal_phpunit_get_extension_namespaces()
drupal_phpunit_populate_class_loader in core/tests/bootstrap.php
Populate class loader with additional namespaces for tests.

File

core/tests/bootstrap.php, line 81

Code

function drupal_phpunit_get_extension_namespaces($dirs) {
    $namespaces = [];
    foreach ($dirs as $extension => $dir) {
        if (is_dir($dir . '/src')) {
            // Register the PSR-4 directory for module-provided classes.
            $namespaces['Drupal\\' . $extension . '\\'][] = $dir . '/src';
        }
        if (is_dir($dir . '/tests/src')) {
            // Register the PSR-4 directory for PHPUnit-based suites.
            $namespaces['Drupal\\Tests\\' . $extension . '\\'][] = $dir . '/tests/src';
        }
    }
    return $namespaces;
}

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