EnableDisableTestCase::assertSuccessfulDisableAndUninstall

7 system.test EnableDisableTestCase::assertSuccessfulDisableAndUninstall($module)
8 system.test EnableDisableTestCase::assertSuccessfulDisableAndUninstall($module)

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

Parameters

$module: The name of the module to disable and uninstall.

File

modules/system/system.test, line 313
Tests for system.module.

Code

function assertSuccessfulDisableAndUninstall($module) {
  // Disable the module.
  $edit = array();
  $edit['modules[Core][' . $module . '][enable]'] = FALSE;
  $this->drupalPost('admin/modules', $edit, t('Save configuration'));
  $this->assertText(t('The configuration options have been saved.'), t('Modules status has been updated.'));
  $this->assertModules(array($module), 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)));
  $this->assertLogMessage('system', "%module module disabled.", array('%module' => $module), WATCHDOG_INFO);

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

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

  // Check that the module's database tables no longer exist.
  $this->assertModuleTablesDoNotExist($module);
}
Login or register to post comments