BackendChainTest.php

Same filename in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Cache/BackendChainTest.php
  2. 8.9.x core/tests/Drupal/KernelTests/Core/Cache/BackendChainTest.php
  3. 11.x core/tests/Drupal/KernelTests/Core/Cache/BackendChainTest.php

Namespace

Drupal\KernelTests\Core\Cache

File

core/tests/Drupal/KernelTests/Core/Cache/BackendChainTest.php

View source
<?php

declare (strict_types=1);
namespace Drupal\KernelTests\Core\Cache;

use Drupal\Component\Datetime\TimeInterface;
use Drupal\Core\Cache\BackendChain;
use Drupal\Core\Cache\MemoryBackend;

/**
 * Unit test of the backend chain using the generic cache unit test base.
 *
 * @group Cache
 */
class BackendChainTest extends GenericCacheBackendUnitTestBase {
    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;
    }

}

Classes

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

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