// Render it twice so that twig caching is triggered.
$this->
assertEquals($expected,
$renderer->
renderRoot($element));
$this->
assertEquals($expected,
$renderer->
renderRoot($element_copy));
$name = '{# inline_template_start #}' .
$element['test'
]['#template'
];
$prefix =
$environment->
getTwigCachePrefix();
$cache =
$environment->
getCache();
$class =
$environment->
getTemplateClass($name);
$expected =
$prefix . '_inline-template_' .
substr(Crypt::
hashBase64($class), 0, TwigPhpStorageCache::SUFFIX_SUBSTRING_LENGTH
);
$this->
assertEquals($expected,
$cache->
generateKey($name,
$class));
} /**
* Tests that exceptions are thrown when a template is not found.
*/
public function testTemplateNotFoundException() { /** @var \Drupal\Core\Template\TwigEnvironment $environment */
$environment = \Drupal::
service('twig'
);
try { $environment->
load('this-template-does-not-exist.html.twig'
)->
render([]);