function NullBackendTest::testNullBackend

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Cache/NullBackendTest.php \Drupal\Tests\Core\Cache\NullBackendTest::testNullBackend()
  2. 8.9.x core/tests/Drupal/Tests/Core/Cache/NullBackendTest.php \Drupal\Tests\Core\Cache\NullBackendTest::testNullBackend()
  3. 10 core/tests/Drupal/Tests/Core/Cache/NullBackendTest.php \Drupal\Tests\Core\Cache\NullBackendTest::testNullBackend()

Tests that the NullBackend does not actually store variables.

File

core/tests/Drupal/Tests/Core/Cache/NullBackendTest.php, line 20

Class

NullBackendTest
Tests the cache NullBackend.

Namespace

Drupal\Tests\Core\Cache

Code

public function testNullBackend() : void {
    $null_cache = new NullBackend('test');
    $key = $this->randomMachineName();
    $value = $this->randomMachineName();
    $null_cache->set($key, $value);
    $this->assertFalse($null_cache->get($key));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.