You are here

protected function InstallUninstallTest::assertSuccessfulUninstall in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php \Drupal\Tests\system\Functional\Module\InstallUninstallTest::assertSuccessfulUninstall()
  2. 10 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.

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 261

Class

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

Namespace

Drupal\Tests\system\Functional\Module

Code

protected function assertSuccessfulUninstall($module, $package = 'Core') {
  $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);
}