function KernelTestBase::getExtensionsForModules

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/KernelTestBase.php \Drupal\KernelTests\KernelTestBase::getExtensionsForModules()
  2. 8.9.x core/tests/Drupal/KernelTests/KernelTestBase.php \Drupal\KernelTests\KernelTestBase::getExtensionsForModules()
  3. 11.x core/tests/Drupal/KernelTests/KernelTestBase.php \Drupal\KernelTests\KernelTestBase::getExtensionsForModules()

Returns Extension objects for $modules to install.

Parameters

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

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 545

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 for testing, include it in the 'require-dev' section of your composer.json file.");
        }
        $extensions[$name] = $list[$name];
    }
    return $extensions;
}

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