1 bootstrap.test | BootstrapResettableStaticTestCase::testBackdropStatic() |
Test that a variable reference returned by backdrop_static() gets reset when backdrop_static_reset() is called.
File
- core/
modules/ simpletest/ tests/ bootstrap.test, line 565
Class
- BootstrapResettableStaticTestCase
- Test that resetting static variables works.
Code
function testBackdropStatic() {
$name = __CLASS__ . '_' . __METHOD__;
$var = &backdrop_static($name, 'foo');
$this->assertEqual($var, 'foo', 'Variable returned by backdrop_static() was set to its default.');
// Call the specific reset and the global reset each twice to ensure that
// multiple resets can be issued without odd side effects.
$var = 'bar';
backdrop_static_reset($name);
$this->assertEqual($var, 'foo', 'Variable was reset after first invocation of name-specific reset.');
$var = 'bar';
backdrop_static_reset($name);
$this->assertEqual($var, 'foo', 'Variable was reset after second invocation of name-specific reset.');
$var = 'bar';
backdrop_static_reset();
$this->assertEqual($var, 'foo', 'Variable was reset after first invocation of global reset.');
$var = 'bar';
backdrop_static_reset();
$this->assertEqual($var, 'foo', 'Variable was reset after second invocation of global reset.');
}