You are here

function drupal_phpunit_get_extension_namespaces in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 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()
bootstrap.php in core/tests/bootstrap.php
Autoloader for Drupal PHPUnit testing.

File

core/tests/bootstrap.php, line 68
Autoloader for Drupal PHPUnit testing.

Code

function drupal_phpunit_get_extension_namespaces($dirs) {
  $namespaces = array();
  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 test classes.
      $namespaces['Drupal\\Tests\\' . $extension . '\\'][] = $dir . '/tests/src';
    }
  }
  return $namespaces;
}