function BackendChainTest::createCacheBackend

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Cache/BackendChainTest.php \Drupal\KernelTests\Core\Cache\BackendChainTest::createCacheBackend()
  2. 8.9.x core/tests/Drupal/KernelTests/Core/Cache/BackendChainTest.php \Drupal\KernelTests\Core\Cache\BackendChainTest::createCacheBackend()
  3. 11.x core/tests/Drupal/KernelTests/Core/Cache/BackendChainTest.php \Drupal\KernelTests\Core\Cache\BackendChainTest::createCacheBackend()

Overrides GenericCacheBackendUnitTestBase::createCacheBackend

File

core/tests/Drupal/KernelTests/Core/Cache/BackendChainTest.php, line 18

Class

BackendChainTest
Unit test of the backend chain using the generic cache unit test base.

Namespace

Drupal\KernelTests\Core\Cache

Code

protected function createCacheBackend($bin) {
    $chain = new BackendChain();
    // We need to create some various backends in the chain.
    $time = \Drupal::service(TimeInterface::class);
    $chain->appendBackend(new MemoryBackend($time))
        ->prependBackend(new MemoryBackend($time))
        ->appendBackend(new MemoryBackend($time));
    \Drupal::service('cache_tags.invalidator')->addInvalidator($chain);
    return $chain;
}

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