You are here

protected function InstallUninstallTest::assertSuccessfulUninstall in Drupal 8

Same name and namespace in other branches
  1. 9 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 263

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
    ->drupalPostForm('admin/modules/uninstall', $edit, t('Uninstall'));
  $this
    ->drupalPostForm(NULL, NULL, t('Uninstall'));
  $this
    ->assertText(t('The selected modules have been uninstalled.'), 'Modules status has been updated.');
  $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
    ->assertText(t('hook_modules_uninstalled fired for @module', [
    '@module' => $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);
}