You are here

function VarsModuleUninstallationTestCase::testModuleUninstallation in Variable API 6

Same name and namespace in other branches
  1. 6.2 tests/vars.test \VarsModuleUninstallationTestCase::testModuleUninstallation()
  2. 7.2 tests/vars.test \VarsModuleUninstallationTestCase::testModuleUninstallation()
  3. 7 tests/vars.test \VarsModuleUninstallationTestCase::testModuleUninstallation()

File

tests/vars.test, line 292
Test file for the Variable API module.

Class

VarsModuleUninstallationTestCase

Code

function testModuleUninstallation() {
  global $conf;
  $vars = new VarsExtendedTestVars();
  $variables = $vars
    ->getDefaults();
  $written_variables = array();
  foreach ($variables as $variable_name => $info) {
    if (!empty($info['flags']) && $info['flags'] == Vars::VARS_DYNAMIC) {
      $var_name = $variable_name . '_' . $this
        ->randomName(16);
    }
    elseif (empty($info['flags'])) {
      $var_name = $variable_name;
    }
    variable_set($var_name, $this
      ->randomName(16));
    $written_variables[] = $var_name;
  }
  $vars
    ->removeDefaults();
  foreach ($written_variables as $variable_name) {
    $this
      ->assertFalse(isset($conf[$variable_name]), t('The variable %var_name has been removed from memory.', array(
      '%var_name' => $variable_name,
    )));
    $this
      ->assertFalse(vars_test_search_variable($variable_name), t('The variable %var_name has been removed from the database table.', array(
      '%var_name' => $variable_name,
    )));
    $this
      ->assertFalse(vars_test_search_default_value($variable_name, 'vars_extended_test'), t('The default value for the variable %var_name has been removed from the database table.', array(
      '%var_name' => $variable_name,
    )));
  }
}