You are here

public function ConfigInstallTest::testDependencyChecking in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/config/src/Tests/ConfigInstallTest.php \Drupal\config\Tests\ConfigInstallTest::testDependencyChecking()

Tests the configuration with unmet dependencies is not installed.

File

core/modules/config/src/Tests/ConfigInstallTest.php, line 200
Contains \Drupal\config\Tests\ConfigInstallTest.

Class

ConfigInstallTest
Tests installation of configuration objects in installation functionality.

Namespace

Drupal\config\Tests

Code

public function testDependencyChecking() {
  $this
    ->installModules([
    'config_test',
  ]);
  try {
    $this
      ->installModules([
      'config_install_dependency_test',
    ]);
    $this
      ->fail('Expected UnmetDependenciesException not thrown.');
  } catch (UnmetDependenciesException $e) {
    $this
      ->assertEqual($e
      ->getExtension(), 'config_install_dependency_test');
    $this
      ->assertEqual($e
      ->getConfigObjects(), [
      'config_test.dynamic.other_module_test_with_dependency',
    ]);
    $this
      ->assertEqual($e
      ->getMessage(), 'Configuration objects (config_test.dynamic.other_module_test_with_dependency) provided by config_install_dependency_test have unmet dependencies');
  }
  $this
    ->installModules([
    'config_other_module_config_test',
  ]);
  $this
    ->installModules([
    'config_install_dependency_test',
  ]);
  $entity = \Drupal::entityManager()
    ->getStorage('config_test')
    ->load('other_module_test_with_dependency');
  $this
    ->assertTrue($entity, 'The config_test.dynamic.other_module_test_with_dependency configuration has been created during install.');

  // Ensure that dependencies can be added during module installation by
  // hooks.
  $this
    ->assertIdentical('config_install_dependency_test', $entity
    ->getDependencies()['module'][0]);
}