function ModuleInstallerTest::testConfigChangeOnInstall

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Extension/ModuleInstallerTest.php \Drupal\KernelTests\Core\Extension\ModuleInstallerTest::testConfigChangeOnInstall()
  2. 8.9.x core/tests/Drupal/KernelTests/Core/Extension/ModuleInstallerTest.php \Drupal\KernelTests\Core\Extension\ModuleInstallerTest::testConfigChangeOnInstall()
  3. 11.x 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 47

Class

ModuleInstallerTest
Tests the ModuleInstaller class.

Namespace

Drupal\KernelTests\Core\Extension

Code

public function testConfigChangeOnInstall() : void {
  // 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.');
}

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