You are here

protected function KernelTestBase::initFileCache in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/KernelTestBase.php \Drupal\KernelTests\KernelTestBase::initFileCache()
  2. 10 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 471

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'])) {

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