function GenericCacheBackendUnitTestBase::getCacheBackend

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/KernelTests/Core/Cache/GenericCacheBackendUnitTestBase.php \Drupal\KernelTests\Core\Cache\GenericCacheBackendUnitTestBase::getCacheBackend()

Gets a backend to test; this will get a shared instance set in the object.

Return value

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

File

core/tests/Drupal/KernelTests/Core/Cache/GenericCacheBackendUnitTestBase.php, line 92

Class

GenericCacheBackendUnitTestBase
Tests any cache backend.

Namespace

Drupal\KernelTests\Core\Cache

Code

protected function getCacheBackend($bin = NULL) {
  if (!isset($bin)) {
    $bin = $this->getTestBin();
  }
  if (!isset($this->cachebackends[$bin])) {
    $this->cachebackends[$bin] = $this->createCacheBackend($bin);
    // Ensure the backend is empty.
    $this->cachebackends[$bin]
      ->deleteAll();
  }
  return $this->cachebackends[$bin];
}

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