You are here

protected function KernelTestBase::initFileCache in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/KernelTests/KernelTestBase.php \Drupal\KernelTests\KernelTestBase::initFileCache()

Initializes the FileCache component.

We can not use the Settings object in a component, that's why we have to do it here instead of \Drupal\Component\FileCache\FileCacheFactory.

1 call to KernelTestBase::initFileCache()
KernelTestBase::setUp in core/tests/Drupal/KernelTests/KernelTestBase.php

File

core/tests/Drupal/KernelTests/KernelTestBase.php, line 500
Contains \Drupal\KernelTests\KernelTestBase.

Class

KernelTestBase
Base class for functional integration tests.

Namespace

Drupal\KernelTests

Code

protected function initFileCache() {
  $configuration = Settings::get('file_cache');

  // Provide a default configuration, if not set.
  if (!isset($configuration['default'])) {
    $configuration['default'] = [
      'class' => FileCache::class,
      'cache_backend_class' => NULL,
      'cache_backend_configuration' => [],
    ];

    // @todo Use extension_loaded('apcu') for non-testbot
    //  https://www.drupal.org/node/2447753.
    if (function_exists('apc_fetch')) {
      $configuration['default']['cache_backend_class'] = ApcuFileCacheBackend::class;
    }
  }
  FileCacheFactory::setConfiguration($configuration);
  FileCacheFactory::setPrefix(Settings::getApcuPrefix('file_cache', $this->root));
}