function KernelTestBase::initFileCache

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/KernelTestBase.php \Drupal\KernelTests\KernelTestBase::initFileCache()
  2. 8.9.x core/tests/Drupal/KernelTests/KernelTestBase.php \Drupal\KernelTests\KernelTestBase::initFileCache()
  3. 11.x 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 515

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));
}

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