You are here

public function ConfigInstallTest::testCollectionInstallationCollectionConfigEntity in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/config/src/Tests/ConfigInstallTest.php \Drupal\config\Tests\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/modules/config/src/Tests/ConfigInstallTest.php, line 173
Contains \Drupal\config\Tests\ConfigInstallTest.

Class

ConfigInstallTest
Tests installation of configuration objects in installation functionality.

Namespace

Drupal\config\Tests

Code

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

  // Install the test module.
  $this
    ->installModules(array(
    '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
    ->assertIdentical(array(
    'label' => 'entity',
  ), $data);
}