function VarsSimpleTestCase::testReadingVars in Variable API 6
Same name and namespace in other branches
- 6.2 tests/vars.test \VarsSimpleTestCase::testReadingVars()
- 7.2 tests/vars.test \VarsSimpleTestCase::testReadingVars()
- 7 tests/vars.test \VarsSimpleTestCase::testReadingVars()
File
- tests/
vars.test, line 60 - Test file for the Variable API module.
Class
Code
function testReadingVars() {
Vars::staticReset();
$read_variables = array(
'menu_rebuild_needed' => variable_get('menu_rebuild_needed', FALSE),
);
$vars = new VarsTestVars();
$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;
}
$read_variables[$var_name] = $info['value'];
}
foreach ($read_variables as $name => $value) {
$this
->assertIdentical($vars[$name], $value, t('The value of the variable %var_name has been retrieved.', array(
'%var_name' => $name,
)));
}
$write_variables = array(
'menu_rebuild_needed' => $this
->randomName(16),
);
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;
}
$write_variables[$var_name] = $this
->randomName(16);
}
foreach ($write_variables as $name => $value) {
$vars[$name] = $value;
$this
->assertIdentical($vars[$name], $value, t('The value of the variable %var_name has been changed.', array(
'%var_name' => $name,
)));
}
}