function KernelTestBase::getExtensionsForModules

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/KernelTestBase.php \Drupal\KernelTests\KernelTestBase::getExtensionsForModules()
  2. 10 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 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 501

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;
}

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