3 namespace Drupal\KernelTests\Core\Theme;
5 use Drupal\Core\Config\InstallStorage;
6 use Drupal\Core\Extension\ExtensionDiscovery;
7 use Drupal\KernelTests\KernelTestBase;
10 * Tests theme settings functionality.
14 class ThemeSettingsTest extends KernelTestBase {
21 public static $modules = ['system'];
24 * List of discovered themes.
28 protected $availableThemes;
30 protected function setUp() {
32 // Theme settings rely on System module's system.theme.global configuration.
33 $this->installConfig(['system']);
35 if (!isset($this->availableThemes)) {
36 $discovery = new ExtensionDiscovery(\Drupal::root());
37 $this->availableThemes = $discovery->scan('theme');
42 * Tests that $theme.settings are imported and used as default theme settings.
44 public function testDefaultConfig() {
45 $name = 'test_basetheme';
46 $path = $this->availableThemes[$name]->getPath();
47 $this->assertTrue(file_exists("$path/" . InstallStorage::CONFIG_INSTALL_DIRECTORY . "/$name.settings.yml"));
48 $this->container->get('theme_handler')->install([$name]);
49 $this->assertIdentical(theme_get_setting('base', $name), 'only');
53 * Tests that the $theme.settings default config file is optional.
55 public function testNoDefaultConfig() {
57 $path = $this->availableThemes[$name]->getPath();
58 $this->assertFalse(file_exists("$path/" . InstallStorage::CONFIG_INSTALL_DIRECTORY . "/$name.settings.yml"));
59 $this->container->get('theme_handler')->install([$name]);
60 $this->assertNotNull(theme_get_setting('features.favicon', $name));