You are here

public function ModuleInstallerTest::testConfigChangeOnInstall in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/Core/Extension/ModuleInstallerTest.php \Drupal\KernelTests\Core\Extension\ModuleInstallerTest::testConfigChangeOnInstall()
  2. 9 core/tests/Drupal/KernelTests/Core/Extension/ModuleInstallerTest.php \Drupal\KernelTests\Core\Extension\ModuleInstallerTest::testConfigChangeOnInstall()

Tests config changes by hook_install() are saved for dependent modules.

@covers ::install

File

core/tests/Drupal/KernelTests/Core/Extension/ModuleInstallerTest.php, line 45

Class

ModuleInstallerTest
Tests the ModuleInstaller class.

Namespace

Drupal\KernelTests\Core\Extension

Code

public function testConfigChangeOnInstall() {

  // Install the child module so the parent is installed automatically.
  $this->container
    ->get('module_installer')
    ->install([
    'module_handler_test_multiple_child',
  ]);
  $modules = $this
    ->config('core.extension')
    ->get('module');
  $this
    ->assertArrayHasKey('module_handler_test_multiple', $modules, 'Module module_handler_test_multiple is installed');
  $this
    ->assertArrayHasKey('module_handler_test_multiple_child', $modules, 'Module module_handler_test_multiple_child is installed');
  $this
    ->assertEquals(1, $modules['module_handler_test_multiple'], 'Weight of module_handler_test_multiple is set.');
  $this
    ->assertEquals(1, $modules['module_handler_test_multiple_child'], 'Weight of module_handler_test_multiple_child is set.');
}