function KernelTestDrupalKernel::getContainerCacheKey

Returns the container cache key based on the environment.

The 'environment' consists of:

  • The kernel environment string.
  • A hash based on all the installed package versions.
  • The deployment identifier from settings.php. This allows custom deployments to force a container rebuild.
  • The operating system running PHP. This allows compiler passes to optimize services for different operating systems.
  • The paths to any additional container YAMLs from settings.php.

Return value

string The cache key used for the service container.

Overrides DrupalKernel::getContainerCacheKey

File

core/lib/Drupal/Core/Test/KernelTestDrupalKernel.php, line 56

Class

KernelTestDrupalKernel
Subclass of DrupalKernel for kernel testing.

Namespace

Drupal\Core\Test

Code

protected function getContainerCacheKey() {
  $key = parent::getContainerCacheKey();
  // Vary by the suffix, so that a container rebuilt during a test method is
  // cached under its own key and does not overwrite the initial container
  // that the other test methods of the class load.
  $key .= ':' . $this->cacheSuffix;
  return $key;
}

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