function KernelTestBase::installConfig

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/KernelTestBase.php \Drupal\KernelTests\KernelTestBase::installConfig()
  2. 8.9.x core/modules/simpletest/src/KernelTestBase.php \Drupal\simpletest\KernelTestBase::installConfig()
  3. 8.9.x core/tests/Drupal/KernelTests/KernelTestBase.php \Drupal\KernelTests\KernelTestBase::installConfig()
  4. 10 core/tests/Drupal/KernelTests/KernelTestBase.php \Drupal\KernelTests\KernelTestBase::installConfig()

Installs default configuration for a given list of modules.

Parameters

string|string[] $modules: A module or list of modules for which to install default configuration.

Throws

\LogicException If any module in $modules is not enabled.

381 calls to KernelTestBase::installConfig()
ActionTest::setUp in core/modules/system/tests/src/Kernel/Action/ActionTest.php
AddItemToToolbarConfigActionTest::setUp in core/modules/ckeditor5/tests/src/Kernel/ConfigAction/AddItemToToolbarConfigActionTest.php
AddModerationConfigActionTest::testAddEntityTypeAndBundle in core/modules/content_moderation/tests/src/Kernel/ConfigAction/AddModerationConfigActionTest.php
AddToAllBundlesConfigActionTest::testFailIfExists in core/modules/field/tests/src/Kernel/AddToAllBundlesConfigActionTest.php
Tests that the action can be set to fail if the field already exists.
AddToAllBundlesConfigActionTest::testIgnoreExistingFields in core/modules/field/tests/src/Kernel/AddToAllBundlesConfigActionTest.php
Tests that the action will ignore existing fields by default.

... See full list

File

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

Class

KernelTestBase
Base class for functional integration tests.

Namespace

Drupal\KernelTests

Code

protected function installConfig($modules) {
    foreach ((array) $modules as $module) {
        if (!$this->container
            ->get('module_handler')
            ->moduleExists($module)) {
            throw new \LogicException("{$module} module is not installed.");
        }
        try {
            $this->container
                ->get('config.installer')
                ->installDefaultConfig('module', $module);
        } catch (\Exception $e) {
            throw new \Exception(sprintf('Exception when installing config for module %s, message was: %s', $module, $e->getMessage()), 0, $e);
        }
    }
}

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