$this->
config('system.theme'
)->
set('default', 'test_theme'
)->
save();
$this->
drupalCreateContentType(['type' => 'page'
]);
// Enable debug, rebuild the service container, and clear all caches.
$parameters =
$this->container->
getParameter('twig.config'
);
$parameters['debug'
] = TRUE;
$this->
setContainerParameter('twig.config',
$parameters);
$this->
rebuildContainer();
$this->
resetAll();
$cache =
$this->container->
get('theme.registry'
)->
get();
// Create array of Twig templates.
$templates =
drupal_find_theme_templates($cache,
$extension,
$this->
getThemePath('test_theme'
));
$templates +=
drupal_find_theme_templates($cache,
$extension,
$this->
getModulePath('node'
));
// Create a node and test different features of the debug markup.
$node =
$this->
drupalCreateNode();
$builder = \Drupal::
entityTypeManager()->
getViewBuilder('node'
);
$build =
$builder->
view($node);
$output =
$renderer->
renderRoot($build);
$this->
assertStringContainsString('<!-- THEME DEBUG -->',
$output, 'Twig debug markup found in theme output when debug is enabled.'
);
$this->
assertStringContainsString("THEME HOOK: 'node'",
$output, 'Theme call information found.'
);
$this->
assertStringContainsString('* node--1--full' .
$extension . PHP_EOL . ' x node--1' .
$extension . PHP_EOL . ' * node--page--full' .
$extension . PHP_EOL . ' * node--page' .
$extension . PHP_EOL . ' * node--full' .
$extension . PHP_EOL . ' * node' .
$extension,
$output, 'Suggested template files found in order and node ID specific template shown as current template.'
);
$this->
assertStringContainsString(Html::
escape('node--<script type="text/javascript">alert(\'yo\');</script>'
),
(string) $output);