function KernelTestBase::installConfig

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

Installs default configuration for a given list of modules.

Parameters

array $modules: A list of modules for which to install default configuration.

Throws

\RuntimeException Thrown when any module listed in $modules is not enabled.

3 calls to KernelTestBase::installConfig()
EntityUnitTestBase::setUp in core/modules/system/src/Tests/Entity/EntityUnitTestBase.php
Performs setup tasks before each individual test method is run.
KernelTestBaseTest::testInstallConfig in core/modules/simpletest/src/Tests/KernelTestBaseTest.php
Tests expected behavior of installConfig().
ViewKernelTestBase::setUpFixtures in core/modules/views/src/Tests/ViewKernelTestBase.php
Sets up the configuration and schema of views and views_test_data modules.

File

core/modules/simpletest/src/KernelTestBase.php, line 436

Class

KernelTestBase
Base class for functional integration tests.

Namespace

Drupal\simpletest

Code

protected function installConfig(array $modules) {
    foreach ($modules as $module) {
        if (!$this->container
            ->get('module_handler')
            ->moduleExists($module)) {
            throw new \RuntimeException("'{$module}' module is not enabled");
        }
        \Drupal::service('config.installer')->installDefaultConfig('module', $module);
    }
    $this->pass(new FormattableMarkup('Installed default config: %modules.', [
        '%modules' => implode(', ', $modules),
    ]));
}

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