function InstallUninstallTest::assertSuccessfulUninstall

Same name and namespace in other branches
  1. 8.9.x core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php \Drupal\Tests\system\Functional\Module\InstallUninstallTest::assertSuccessfulUninstall()

Uninstalls a module and asserts that it was done correctly.

@internal

Parameters

string $module: The name of the module to uninstall.

string $package: (optional) The package of the module to uninstall. Defaults to 'Core'.

1 call to InstallUninstallTest::assertSuccessfulUninstall()
InstallUninstallTest::testInstallUninstall in core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php
Tests that a fixed set of modules can be installed and uninstalled.

File

core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php, line 310

Class

InstallUninstallTest
Install/uninstall core module and confirm table creation/deletion.

Namespace

Drupal\Tests\system\Functional\Module

Code

protected function assertSuccessfulUninstall(string $module, string $package = 'Core') : void {
  $edit = [];
  $edit['uninstall[' . $module . ']'] = TRUE;
  $this->drupalGet('admin/modules/uninstall');
  $this->submitForm($edit, 'Uninstall');
  $this->submitForm([], 'Uninstall');
  $this->assertSession()
    ->pageTextContains('The selected modules have been uninstalled.');
  $this->assertModules([
    $module,
  ], FALSE);
  // Check that the appropriate hook was fired and the appropriate log
  // message appears. (But don't check for the log message if the dblog
  // module was just uninstalled, since the {watchdog} table won't be there
  // anymore.)
  $this->assertSession()
    ->pageTextContains('hook_modules_uninstalled fired for ' . $module);
  $this->assertLogMessage('system', "%module module uninstalled.", [
    '%module' => $module,
  ], RfcLogLevel::INFO);
  // Check that the module's database tables no longer exist.
  $this->assertModuleTablesDoNotExist($module);
  // Check that the module's config files no longer exist.
  $this->assertNoModuleConfig($module);
  $this->assertUninstallModuleUpdates($module);
}

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