StableTemplateOverrideTest.php in Zircon Profile 8
File
core/tests/Drupal/KernelTests/Core/Theme/StableTemplateOverrideTest.php
View source
<?php
namespace Drupal\KernelTests\Core\Theme;
use Drupal\Core\Theme\Registry;
use Drupal\KernelTests\KernelTestBase;
class StableTemplateOverrideTest extends KernelTestBase {
public static $modules = [
'system',
'user',
];
protected $templatesToSkip = [
'views-form-views-form',
];
protected $themeHandler;
protected $allModules;
public function setUp() {
parent::setUp();
$this->themeHandler = $this->container
->get('theme_handler');
$this->container
->get('theme_installer')
->install([
'stable',
]);
$this
->installSchema('system', 'router');
$this
->installAllModules();
}
protected function installAllModules() {
include_once $this->root . '/core/modules/system/system.module';
$all_modules = system_rebuild_module_data();
$all_modules = array_filter($all_modules, function ($module) {
if ($module->origin !== 'core' || !empty($module->info['hidden']) || $module->status == TRUE || $module->info['package'] == 'Testing') {
return FALSE;
}
return TRUE;
});
$this->allModules = array_keys($all_modules);
sort($this->allModules);
$module_installer = $this->container
->get('module_installer');
$module_installer
->install($this->allModules);
$this
->installConfig([
'system',
'user',
]);
}
public function testStableTemplateOverrides() {
$registry = new Registry(\Drupal::root(), \Drupal::cache(), \Drupal::lock(), \Drupal::moduleHandler(), $this->themeHandler, \Drupal::service('theme.initialization'), 'stable');
$registry
->setThemeManager(\Drupal::theme());
$registry_full = $registry
->get();
foreach ($registry_full as $hook => $info) {
if (isset($info['template'])) {
if (in_array($info['template'], $this->templatesToSkip)) {
continue;
}
$this
->assertEquals('core/themes/stable', $info['theme path'], $info['template'] . '.html.twig overridden in Stable.');
}
}
}
}