diff -u b/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php --- b/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -71,7 +71,17 @@ * Initializes the service container. */ protected function initializeContainer() { - // PHP identifiers always start with a letter. Hashes don't. + // While the default Synfomy class name only depends on the environment, + // for testing purposes we can't use that because there would be a + // collission as each test method creates a new kernel.. On the other hand, + // the container only depends on the enabled modules (and only on those + // that provide bundles) so we base the name of the container class on + // the hash of the enabled modules. We can't use directly the hash though + // because PHP identifiers always start with a letter. and hashes don't so + // we add a charater to the beginning. This mechanism also avoids the + // problem of needing to rebuild the DIC at the right time on module + // enable: simply on the next request the hash will change and so the + // container will be rebuilt. $class = 'c' . $this->systemList['module_enabled_hash']; $cache_file = $class . '.php';