You are here

private function KernelTestBase::getExtensionsForModules in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/KernelTestBase.php \Drupal\KernelTests\KernelTestBase::getExtensionsForModules()
  2. 10 core/tests/Drupal/KernelTests/KernelTestBase.php \Drupal\KernelTests\KernelTestBase::getExtensionsForModules()

Returns Extension objects for $modules to enable.

Parameters

string[] $modules: The list of modules to enable.

Return value

\Drupal\Core\Extension\Extension[] Extension objects for $modules, keyed by module name.

Throws

\PHPUnit\Framework\Exception If a module is not available.

See also

\Drupal\Tests\KernelTestBase::enableModules()

\Drupal\Core\Extension\ModuleHandler::add()

1 call to KernelTestBase::getExtensionsForModules()
KernelTestBase::bootKernel in core/tests/Drupal/KernelTests/KernelTestBase.php
Bootstraps a kernel for a test.

File

core/tests/Drupal/KernelTests/KernelTestBase.php, line 511

Class

KernelTestBase
Base class for functional integration tests.

Namespace

Drupal\KernelTests

Code

private function getExtensionsForModules(array $modules) {
  $extensions = [];
  $discovery = new ExtensionDiscovery($this->root);
  $discovery
    ->setProfileDirectories([]);
  $list = $discovery
    ->scan('module');
  foreach ($modules as $name) {
    if (!isset($list[$name])) {
      throw new Exception("Unavailable module: '{$name}'. If this module needs to be downloaded separately, annotate the test class with '@requires module {$name}'.");
    }
    $extensions[$name] = $list[$name];
  }
  return $extensions;
}