class ResettableStaticTest
Same name and namespace in other branches
- 11.x core/tests/Drupal/KernelTests/Core/Bootstrap/ResettableStaticTest.php \Drupal\KernelTests\Core\Bootstrap\ResettableStaticTest
- 10 core/tests/Drupal/KernelTests/Core/Bootstrap/ResettableStaticTest.php \Drupal\KernelTests\Core\Bootstrap\ResettableStaticTest
- 8.9.x core/tests/Drupal/KernelTests/Core/Bootstrap/ResettableStaticTest.php \Drupal\KernelTests\Core\Bootstrap\ResettableStaticTest
Tests that drupal_static() and drupal_static_reset() work.
@group Bootstrap
Hierarchy
- class \Drupal\KernelTests\KernelTestBase implements \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\KernelTests\Core\Bootstrap\ResettableStaticTest extends \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of ResettableStaticTest
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Bootstrap/ ResettableStaticTest.php, line 12
Namespace
Drupal\KernelTests\Core\BootstrapView source
class ResettableStaticTest extends KernelTestBase {
/**
* Tests drupal_static() function.
*
* Tests that a variable reference returned by drupal_static() gets reset when
* drupal_static_reset() is called.
*/
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.');
// 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->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.');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.