public function assertPageRenderHookExceptions(string
$module, string
$hook): void
{ $html_renderer = \Drupal::
getContainer()->
get('main_content_renderer.html'
);
// Assert a valid hook implementation doesn't trigger an exception.
$page =
[];
$html_renderer->
invokePageAttachmentHooks($page);
// Assert that hooks can set cache tags.
$this->
assertEquals(['example'
],
$page['#cache'
]['tags'
]);
$this->
assertEquals(['user.permissions'
],
$page['#cache'
]['contexts'
]);
// Assert an invalid hook implementation doesn't trigger an exception.
\Drupal::
state()->
set($module . '.' .
$hook . '.descendant_attached', TRUE
);
$assertion =
$hook . '() implementation that sets #attached on a descendant triggers an exception';
$page =
[];
try { $html_renderer->
invokePageAttachmentHooks($page);