function VarsExtendedTestCase::testDeletingVars in Variable API 6
Same name and namespace in other branches
- 6.2 tests/vars.test \VarsExtendedTestCase::testDeletingVars()
- 7.2 tests/vars.test \VarsExtendedTestCase::testDeletingVars()
- 7 tests/vars.test \VarsExtendedTestCase::testDeletingVars()
File
- tests/
vars.test, line 198 - Test file for the Variable API module.
Class
Code
function testDeletingVars() {
global $conf;
$written_variables = array();
Vars::staticReset();
$vars = new VarsExtendedTestVars();
$variables = $vars
->getDefaults();
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::deleteVariables($written_variables);
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,
)));
}
}