You are here

private function KernelTestBase::getExtensionsForModules in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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()

2 calls to KernelTestBase::getExtensionsForModules()
KernelTestBase::bootKernel in core/tests/Drupal/KernelTests/KernelTestBase.php
Bootstraps a kernel for a test.
KernelTestBase::getCompiledContainerBuilder in core/tests/Drupal/KernelTests/KernelTestBase.php
Prepares a precompiled ContainerBuilder for all tests of this class.

File

core/tests/Drupal/KernelTests/KernelTestBase.php, line 535
Contains \Drupal\KernelTests\KernelTestBase.

Class

KernelTestBase
Base class for functional integration tests.

Namespace

Drupal\KernelTests

Code

private function getExtensionsForModules(array $modules) {
  $extensions = array();
  $discovery = new ExtensionDiscovery($this->root);
  $discovery
    ->setProfileDirectories(array());
  $list = $discovery
    ->scan('module');
  foreach ($modules as $name) {
    if (!isset($list[$name])) {
      throw new \PHPUnit_Framework_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;
}