BaseThemeRequiredTest.php

Same filename in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Theme/BaseThemeRequiredTest.php
  2. 10 core/tests/Drupal/KernelTests/Core/Theme/BaseThemeRequiredTest.php
  3. 11.x core/tests/Drupal/KernelTests/Core/Theme/BaseThemeRequiredTest.php

Namespace

Drupal\KernelTests\Core\Theme

File

core/tests/Drupal/KernelTests/Core/Theme/BaseThemeRequiredTest.php

View source
<?php

namespace Drupal\KernelTests\Core\Theme;

use Drupal\KernelTests\KernelTestBase;

/**
 * Tests the behavior of the `base theme` key.
 *
 * @group Theme
 */
class BaseThemeRequiredTest extends KernelTestBase {
    
    /**
     * {@inheritdoc}
     */
    public static $modules = [
        'system',
    ];
    
    /**
     * The theme installer.
     *
     * @var \Drupal\Core\Extension\ThemeInstallerInterface
     */
    protected $themeInstaller;
    
    /**
     * The theme manager.
     *
     * @var \Drupal\Core\Theme\ThemeManagerInterface
     */
    protected $themeManager;
    
    /**
     * {@inheritdoc}
     */
    protected function setUp() {
        parent::setUp();
        $this->themeInstaller = $this->container
            ->get('theme_installer');
        $this->themeManager = $this->container
            ->get('theme.manager');
    }
    
    /**
     * Tests opting out of Stable by setting the base theme to false.
     */
    public function testWildWest() {
        $this->themeInstaller
            ->install([
            'test_wild_west',
        ]);
        $this->config('system.theme')
            ->set('default', 'test_wild_west')
            ->save();
        $theme = $this->themeManager
            ->getActiveTheme();
        
        /** @var \Drupal\Core\Theme\ActiveTheme $base_theme */
        $base_themes = $theme->getBaseThemeExtensions();
        $this->assertTrue(empty($base_themes), 'No base theme is set when a theme has opted out of using Stable.');
    }

}

Classes

Title Deprecated Summary
BaseThemeRequiredTest Tests the behavior of the `base theme` key.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.