function InstallProfileDependenciesTest::testUninstallingModules

Same name and namespace in other branches
  1. 9 core/tests/Drupal/FunctionalTests/Installer/InstallProfileDependenciesTest.php \Drupal\FunctionalTests\Installer\InstallProfileDependenciesTest::testUninstallingModules()
  2. 8.9.x core/tests/Drupal/FunctionalTests/Installer/InstallProfileDependenciesTest.php \Drupal\FunctionalTests\Installer\InstallProfileDependenciesTest::testUninstallingModules()
  3. 11.x core/tests/Drupal/FunctionalTests/Installer/InstallProfileDependenciesTest.php \Drupal\FunctionalTests\Installer\InstallProfileDependenciesTest::testUninstallingModules()

Tests that an install profile can require modules.

File

core/tests/Drupal/FunctionalTests/Installer/InstallProfileDependenciesTest.php, line 30

Class

InstallProfileDependenciesTest
Tests that an install profile can require modules.

Namespace

Drupal\FunctionalTests\Installer

Code

public function testUninstallingModules() : void {
  $user = $this->drupalCreateUser([
    'administer modules',
  ]);
  $this->drupalLogin($user);
  $this->drupalGet('admin/modules/uninstall');
  $this->assertSession()
    ->fieldDisabled('uninstall[dblog]');
  $this->getSession()
    ->getPage()
    ->checkField('uninstall[ban]');
  $this->click('#edit-submit');
  // Click the confirm button.
  $this->click('#edit-submit');
  $this->assertSession()
    ->responseContains('The selected modules have been uninstalled.');
  // We've uninstalled a module therefore we need to rebuild the container in
  // the test runner.
  $this->rebuildContainer();
  $this->assertFalse($this->container
    ->get('module_handler')
    ->moduleExists('ban'));
  try {
    $this->container
      ->get('module_installer')
      ->uninstall([
      'dblog',
    ]);
    $this->fail('Uninstalled dblog module.');
  } catch (ModuleUninstallValidatorException $e) {
    $this->assertStringContainsString("The 'Testing install profile dependencies' install profile requires 'Database Logging'", $e->getMessage());
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.