You are here

public function ConfigInstallTest::testCollectionInstallationCollectionConfigEntity in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Config/ConfigInstallTest.php \Drupal\KernelTests\Core\Config\ConfigInstallTest::testCollectionInstallationCollectionConfigEntity()
  2. 10 core/tests/Drupal/KernelTests/Core/Config/ConfigInstallTest.php \Drupal\KernelTests\Core\Config\ConfigInstallTest::testCollectionInstallationCollectionConfigEntity()

Tests collections which do not support config entities install correctly.

Config entity detection during config installation is done by matching config name prefixes. If a collection provides a configuration with a matching name but does not support config entities it should be created using simple configuration.

File

core/tests/Drupal/KernelTests/Core/Config/ConfigInstallTest.php, line 168

Class

ConfigInstallTest
Tests installation of configuration objects in installation functionality.

Namespace

Drupal\KernelTests\Core\Config

Code

public function testCollectionInstallationCollectionConfigEntity() {
  $collections = [
    'entity',
  ];
  \Drupal::state()
    ->set('config_collection_install_test.collection_names', $collections);

  // Install the test module.
  $this
    ->installModules([
    'config_test',
    'config_collection_install_test',
  ]);

  /** @var \Drupal\Core\Config\StorageInterface $active_storage */
  $active_storage = \Drupal::service('config.storage');
  $this
    ->assertEqual($collections, $active_storage
    ->getAllCollectionNames());
  $collection_storage = $active_storage
    ->createCollection('entity');

  // The config_test.dynamic.dotted.default configuration object saved in the
  // active store should be a configuration entity complete with UUID. Because
  // the entity collection does not support configuration entities the
  // configuration object stored there with the same name should only contain
  // a label.
  $name = 'config_test.dynamic.dotted.default';
  $data = $active_storage
    ->read($name);
  $this
    ->assertTrue(isset($data['uuid']));
  $data = $collection_storage
    ->read($name);
  $this
    ->assertSame([
    'label' => 'entity',
  ], $data);
}