You are here

protected function BackendChainUnitTest::createCacheBackend in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Cache/BackendChainUnitTest.php \Drupal\system\Tests\Cache\BackendChainUnitTest::createCacheBackend()

Creates a cache backend to test.

Override this method to test a CacheBackend.

Parameters

string $bin: Bin name to use for this backend instance.

Return value

\Drupal\Core\Cache\CacheBackendInterface Cache backend to test.

Overrides GenericCacheBackendUnitTestBase::createCacheBackend

File

core/modules/system/src/Tests/Cache/BackendChainUnitTest.php, line 20
Contains \Drupal\system\Tests\Cache\BackendChainUnitTest.

Class

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

Namespace

Drupal\system\Tests\Cache

Code

protected function createCacheBackend($bin) {
  $chain = new BackendChain($bin);

  // We need to create some various backends in the chain.
  $chain
    ->appendBackend(new MemoryBackend('foo'))
    ->prependBackend(new MemoryBackend('bar'))
    ->appendBackend(new MemoryBackend('baz'));
  \Drupal::service('cache_tags.invalidator')
    ->addInvalidator($chain);
  return $chain;
}