You are here

public function ConfigSelectorTest::testConfigSelectorMultipleFeatures in Configuration selector 8.2

Same name and namespace in other branches
  1. 8 tests/src/Kernel/ConfigSelectorTest.php \Drupal\Tests\config_selector\Kernel\ConfigSelectorTest::testConfigSelectorMultipleFeatures()

Tests \Drupal\config_selector\ConfigSelector().

Tests installing a module that provides multiple features with multiple versions.

File

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

Class

ConfigSelectorTest
Tests the ConfigSelector.

Namespace

Drupal\Tests\config_selector\Kernel

Code

public function testConfigSelectorMultipleFeatures() {

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

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

  // Lower priority than feature_a_two.
  $this
    ->assertFalse($configs['feature_a_one']
    ->status());

  // Lower priority than feature_a_two.
  $this
    ->assertFalse($configs['feature_a_three']
    ->status());

  // Higher priority but it is disabled in default configuration.
  $this
    ->assertFalse($configs['feature_a_four']
    ->status());
  $this
    ->assertTrue($configs['feature_b_two']
    ->status());
  $this
    ->assertFalse($configs['feature_b_one']
    ->status());
  $this
    ->assertTrue($configs['feature_c_one']
    ->status());
}