function ResettableStaticUnitTest::testDrupalStatic in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Bootstrap/ResettableStaticUnitTest.php \Drupal\system\Tests\Bootstrap\ResettableStaticUnitTest::testDrupalStatic()
Tests drupal_static() function.
Tests that a variable reference returned by drupal_static() gets reset when drupal_static_reset() is called.
File
- core/
modules/ system/ src/ Tests/ Bootstrap/ ResettableStaticUnitTest.php, line 25 - Contains \Drupal\system\Tests\Bootstrap\ResettableStaticUnitTest.
Class
- ResettableStaticUnitTest
- Tests that drupal_static() and drupal_static_reset() work.
Namespace
Drupal\system\Tests\BootstrapCode
function testDrupalStatic() {
$name = __CLASS__ . '_' . __METHOD__;
$var =& drupal_static($name, 'foo');
$this
->assertEqual($var, 'foo', 'Variable returned by drupal_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';
drupal_static_reset($name);
$this
->assertEqual($var, 'foo', 'Variable was reset after first invocation of name-specific reset.');
$var = 'bar';
drupal_static_reset($name);
$this
->assertEqual($var, 'foo', 'Variable was reset after second invocation of name-specific reset.');
$var = 'bar';
drupal_static_reset();
$this
->assertEqual($var, 'foo', 'Variable was reset after first invocation of global reset.');
$var = 'bar';
drupal_static_reset();
$this
->assertEqual($var, 'foo', 'Variable was reset after second invocation of global reset.');
}