You are here

public function ConfigSelectorTest::testConfigSelectorMultipleModuleInstall in Configuration selector 8.2

Tests \Drupal\config_selector\ConfigSelector().

Tests installing multiple modules at the same time.

File

tests/src/Kernel/ConfigSelectorTest.php, line 334

Class

ConfigSelectorTest
Tests the ConfigSelector.

Namespace

Drupal\Tests\config_selector\Kernel

Code

public function testConfigSelectorMultipleModuleInstall() {

  /** @var \Drupal\Core\Extension\ModuleInstallerInterface $module_installer */
  $module_installer = $this->container
    ->get('module_installer');

  // Install a module that has configuration with config_selector third party
  // settings for the ConfigSelector to process..
  $module_installer
    ->install([
    'config_selector_test_one',
  ]);

  /** @var \Drupal\Core\Config\Entity\ConfigEntityInterface[] $configs */
  $configs = \Drupal::entityTypeManager()
    ->getStorage('config_test')
    ->loadMultiple();
  $this
    ->assertTrue($configs['feature_a_one']
    ->status());
  $this
    ->assertArrayNotHasKey('feature_a_two', $configs);
  $this
    ->assertArrayNotHasKey('feature_a_three', $configs);
  $this
    ->assertMessages([]);
  $this
    ->clearLogger();

  // Install another module that will cause config_test.dynamic.feature_a_two
  // to be installed. This configuration has a higher priority than
  // config_test.dynamic.feature_a_one. Therefore, feature_a_one will be
  // disabled and feature_a_two will be enabled.
  $module_installer
    ->install([
    'config_selector_test_two',
    'config_selector_zzzzz_test',
  ]);
  $configs = \Drupal::entityTypeManager()
    ->getStorage('config_test')
    ->loadMultiple();
  $this
    ->assertFalse($configs['feature_a_one']
    ->status());
  $this
    ->assertTrue($configs['feature_a_two']
    ->status());
  $this
    ->assertArrayNotHasKey('feature_a_three', $configs);
  $this
    ->assertMessages([
    'Configuration <a href="/admin/structure/config_test/manage/feature_a_one">Feature A version 1</a> has been disabled in favor of <a href="/admin/structure/config_test/manage/feature_a_two">Feature A version 2</a>.',
  ]);
  $this
    ->clearLogger();
}