ResettableStaticTest.php in Drupal 10
File
core/tests/Drupal/KernelTests/Core/Bootstrap/ResettableStaticTest.php
View source
<?php
namespace Drupal\KernelTests\Core\Bootstrap;
use Drupal\KernelTests\KernelTestBase;
class ResettableStaticTest extends KernelTestBase {
public function testDrupalStatic() {
$name = __CLASS__ . '_' . __METHOD__;
$var =& drupal_static($name, 'foo');
$this
->assertEquals('foo', $var, 'Variable returned by drupal_static() was set to its default.');
$var = 'bar';
drupal_static_reset($name);
$this
->assertEquals('foo', $var, 'Variable was reset after first invocation of name-specific reset.');
$var = 'bar';
drupal_static_reset($name);
$this
->assertEquals('foo', $var, 'Variable was reset after second invocation of name-specific reset.');
$var = 'bar';
drupal_static_reset();
$this
->assertEquals('foo', $var, 'Variable was reset after first invocation of global reset.');
$var = 'bar';
drupal_static_reset();
$this
->assertEquals('foo', $var, 'Variable was reset after second invocation of global reset.');
}
}