You are here

protected function PersistentFileSystemBackendTest::createCacheBackend in File Cache 8

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 FileSystemBackendTest::createCacheBackend

File

tests/src/Kernel/PersistentFileSystemBackendTest.php, line 18

Class

PersistentFileSystemBackendTest
Tests the FileSystemBackend cache backend using the persistent option.

Namespace

Drupal\Tests\filecache\Kernel

Code

protected function createCacheBackend($bin) {

  // Set the FileSystemBackend as the default cache backend.
  $this
    ->setSetting('cache', [
    'default' => 'cache.backend.file_system',
  ]);
  $base_path = file_default_scheme() . '://filecache';
  $settings = [
    'directory' => [
      'default' => $base_path,
      'bins' => [
        'foo' => $base_path . '/foo',
        'bar' => $base_path . '/bar',
      ],
    ],
    'strategy' => [
      'default' => FileSystemBackend::PERSIST,
      'bins' => [
        'foo' => FileSystemBackend::PERSIST,
        'bar' => FileSystemBackend::PERSIST,
      ],
    ],
  ];
  $this
    ->setSetting('filecache', $settings);
  return $this->container
    ->get('cache.backend.file_system')
    ->get($bin);
}