diff --git a/core/modules/system/src/Tests/Theme/TwigEnvironmentTest.php b/core/modules/system/src/Tests/Theme/TwigEnvironmentTest.php index 235db35..ecf38b1 100644 --- a/core/modules/system/src/Tests/Theme/TwigEnvironmentTest.php +++ b/core/modules/system/src/Tests/Theme/TwigEnvironmentTest.php @@ -83,5 +83,34 @@ public function testTemplateNotFoundException() { } } + /** + * Ensures that cacheFilename() varies by extensions + deployment identifier. + */ + public function testCacheFilename() { + /** @var \Drupal\Core\Template\TwigEnvironment $environment */ + // Note: Later we refetch the twig service in order to bypass its internal + // static cache. + $environment = \Drupal::service('twig'); + + $original_filename = $environment->getCacheFilename('core/modules/system/templates/container.html.twig'); + \Drupal::getContainer()->set('twig', NULL); + + \Drupal::service('module_installer')->install(['twig_extension_test']); + $environment = \Drupal::service('twig'); + $new_extension_filename = $environment->getCacheFilename('core/modules/system/templates/container.html.twig'); + \Drupal::getContainer()->set('twig', NULL); + + // Change the deployment identifier. + $settings = Settings::getAll(); + $settings['deployment_identifier'] = '7297'; + new Settings($settings); + + $environment = \Drupal::service('twig'); + $deyploment_identifier_change_filename = $environment->getCacheFilename('core/modules/system/templates/container.html.twig'); + + $this->assertNotEqual($new_extension_filename, $original_filename); + $this->assertNotEqual($deyploment_identifier_change_filename, $original_filename); + } + }