ActiveThemeLegacyTest.php in Drupal 8
File
core/tests/Drupal/KernelTests/Core/Theme/ActiveThemeLegacyTest.php
View source
<?php
namespace Drupal\KernelTests\Core\Theme;
use Drupal\Core\Theme\ActiveTheme;
use Drupal\KernelTests\KernelTestBase;
class ActiveThemeLegacyTest extends KernelTestBase {
protected static $modules = [
'system',
];
public function testGetBaseThemes() {
$this->container
->get('theme_installer')
->install([
'test_subsubtheme',
]);
$this
->config('system.theme')
->set('default', 'test_subsubtheme')
->save();
$active_theme = \Drupal::theme()
->getActiveTheme();
$base_themes = $active_theme
->getBaseThemes();
$this
->assertInstanceOf(ActiveTheme::class, $base_themes['test_subtheme']);
$this
->assertSame([
'test_subtheme',
'test_basetheme',
], array_keys($base_themes));
$test_subtheme_base_themes = $base_themes['test_subtheme']
->getBaseThemes();
$this
->assertSame([
'test_basetheme',
], array_keys($test_subtheme_base_themes));
$this
->assertEmpty($test_subtheme_base_themes['test_basetheme']
->getBaseThemes());
}
public function testConstructor() {
$themes = $this->container
->get('extension.list.theme')
->getList();
$values = [
'name' => $themes['test_basetheme']
->getName(),
'extension' => $themes['test_basetheme'],
];
$base_active_theme = new ActiveTheme($values);
$values = [
'name' => $themes['test_subtheme']
->getName(),
'extension' => $themes['test_subtheme'],
'base_themes' => [
'test_basetheme' => $base_active_theme,
],
];
$active_theme = new ActiveTheme($values);
$base_extensions = $active_theme
->getBaseThemeExtensions();
$this
->assertSame($base_extensions['test_basetheme'], $themes['test_basetheme']);
$this
->assertSame([
'test_basetheme',
], array_keys($base_extensions));
}
}