You are here

protected function GenericCacheBackendUnitTestBase::getCacheBackend in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php \Drupal\system\Tests\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.

13 calls to GenericCacheBackendUnitTestBase::getCacheBackend()
ApcuBackendUnitTest::testSetGet in core/modules/system/src/Tests/Cache/ApcuBackendUnitTest.php
Tests the get and set methods of Drupal\Core\Cache\CacheBackendInterface.
DatabaseBackendUnitTest::testSetGet in core/modules/system/src/Tests/Cache/DatabaseBackendUnitTest.php
Tests the get and set methods of Drupal\Core\Cache\CacheBackendInterface.
GenericCacheBackendUnitTestBase::testDelete in core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php
Tests Drupal\Core\Cache\CacheBackendInterface::delete().
GenericCacheBackendUnitTestBase::testDeleteAll in core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php
Test Drupal\Core\Cache\CacheBackendInterface::deleteAll().
GenericCacheBackendUnitTestBase::testDeleteMultiple in core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php
Test Drupal\Core\Cache\CacheBackendInterface::delete() and Drupal\Core\Cache\CacheBackendInterface::deleteMultiple().

... See full list

File

core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php, line 97
Contains \Drupal\system\Tests\Cache\GenericCacheBackendUnitTestBase.

Class

GenericCacheBackendUnitTestBase
Tests any cache backend.

Namespace

Drupal\system\Tests\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];
}