You are here

public function ConfigInstallWebTest::testUnmetDependenciesInstall in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/config/tests/src/Functional/ConfigInstallWebTest.php \Drupal\Tests\config\Functional\ConfigInstallWebTest::testUnmetDependenciesInstall()

Tests unmet dependencies detection.

File

core/modules/config/tests/src/Functional/ConfigInstallWebTest.php, line 197

Class

ConfigInstallWebTest
Tests installation and removal of configuration objects in install, disable and uninstall functionality.

Namespace

Drupal\Tests\config\Functional

Code

public function testUnmetDependenciesInstall() {
  $this
    ->drupalLogin($this->adminUser);

  // We need to install separately since config_install_dependency_test does
  // not depend on config_test and order is important.
  $this
    ->drupalGet('admin/modules');
  $this
    ->submitForm([
    'modules[config_test][enable]' => TRUE,
  ], 'Install');
  $this
    ->drupalGet('admin/modules');
  $this
    ->submitForm([
    'modules[config_install_dependency_test][enable]' => TRUE,
  ], 'Install');
  $this
    ->assertSession()
    ->responseContains('Unable to install <em class="placeholder">Config install dependency test</em> due to unmet dependencies: <em class="placeholder">config_test.dynamic.other_module_test_with_dependency (config_other_module_config_test, config_test.dynamic.dotted.english)</em>');
  $this
    ->drupalGet('admin/modules');
  $this
    ->submitForm([
    'modules[config_test_language][enable]' => TRUE,
  ], 'Install');
  $this
    ->drupalGet('admin/modules');
  $this
    ->submitForm([
    'modules[config_install_dependency_test][enable]' => TRUE,
  ], 'Install');
  $this
    ->assertSession()
    ->responseContains('Unable to install <em class="placeholder">Config install dependency test</em> due to unmet dependencies: <em class="placeholder">config_test.dynamic.other_module_test_with_dependency (config_other_module_config_test)</em>');
  $this
    ->drupalGet('admin/modules');
  $this
    ->submitForm([
    'modules[config_other_module_config_test][enable]' => TRUE,
  ], 'Install');
  $this
    ->drupalGet('admin/modules');
  $this
    ->submitForm([
    'modules[config_install_dependency_test][enable]' => TRUE,
  ], 'Install');
  $this
    ->rebuildContainer();
  $this
    ->assertInstanceOf(ConfigTest::class, \Drupal::entityTypeManager()
    ->getStorage('config_test')
    ->load('other_module_test_with_dependency'));
}