1 system.test EnableDisableTestCase::assertSuccessfulDisableAndUninstall($module)

Disables and uninstalls a module and asserts that it was done correctly.

Parameters

$module: The complete object representing the module to disable and uninstall, as retrieved with system_rebuild_module_data().

File

core/modules/system/tests/system.test, line 272
Tests for system.module.

Class

EnableDisableTestCase
Test module enabling/disabling functionality.

Code

function assertSuccessfulDisableAndUninstall($module) {
  // Disable the module.
  $edit = array();
  $edit['modules[' . $module->info['package'] . '][' . $module->name . '][enable]'] = FALSE;
  $this->backdropPost('admin/modules', $edit, t('Save configuration'));
  $this->assertText(t('The configuration options have been saved.'), 'Modules status has been updated.');
  $this->assertModules(array($module->name), FALSE);

  // Check that the appropriate hook was fired and the appropriate log
  // message appears.
  $this->assertText(t('hook_modules_disabled fired for @module', array('@module' => $module->name)));
  $this->assertLogMessage('system', "%module module disabled.", array('%module' => $module->name), WATCHDOG_INFO);

  //  Check that the module's database tables still exist.
  $this->assertModuleTablesExist($module->name);

  // Uninstall the module.
  $edit = array();
  $edit['uninstall[' . $module->name . ']'] = $module->name;
  $this->backdropPost('admin/modules/uninstall', $edit, t('Uninstall'));
  $this->backdropPost(NULL, NULL, t('Uninstall'));
  $this->assertText(t('The selected modules have been uninstalled.'), 'Modules status has been updated.');
  $this->assertModules(array($module->name), 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', array('@module' => $module->name)));
  if ($module->name != 'dblog') {
    $this->assertLogMessage('system', "%module module uninstalled.", array('%module' => $module->name), WATCHDOG_INFO);
  }

  // Check that the module's database tables no longer exist.
  $this->assertModuleTablesDoNotExist($module->name);
}