You are here

public function ApcuBackendTest::testSetGet in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/Core/Cache/ApcuBackendTest.php \Drupal\KernelTests\Core\Cache\ApcuBackendTest::testSetGet()

Tests the get and set methods of Drupal\Core\Cache\CacheBackendInterface.

Overrides GenericCacheBackendUnitTestBase::testSetGet

File

core/tests/Drupal/KernelTests/Core/Cache/ApcuBackendTest.php, line 35

Class

ApcuBackendTest
Tests the APCu cache backend.

Namespace

Drupal\KernelTests\Core\Cache

Code

public function testSetGet() {
  parent::testSetGet();

  // Make sure entries are permanent (i.e. no TTL).
  $backend = $this
    ->getCacheBackend($this
    ->getTestBin());
  $key = $backend
    ->getApcuKey('TEST8');
  $iterator = new \APCUIterator('/^' . $key . '/');
  foreach ($iterator as $item) {
    $this
      ->assertEquals(0, $item['ttl']);
    $found = TRUE;
  }
  $this
    ->assertTrue($found);
}