3 namespace Drupal\KernelTests\Core\Theme;
5 use Drupal\KernelTests\KernelTestBase;
8 * Tests the behavior of the Stable theme.
12 class StableThemeTest extends KernelTestBase {
19 public static $modules = ['system'];
24 * @var \Drupal\Core\Extension\ThemeHandlerInterface
26 protected $themeHandler;
31 * @var \Drupal\Core\Theme\ThemeManagerInterface
33 protected $themeManager;
38 protected function setUp() {
41 $this->themeHandler = $this->container->get('theme_handler');
42 $this->themeManager = $this->container->get('theme.manager');
46 * Ensures Stable is used by default when no base theme has been defined.
48 public function testStableIsDefault() {
49 $this->themeHandler->install(['test_stable']);
50 $this->config('system.theme')->set('default', 'test_stable')->save();
51 $theme = $this->themeManager->getActiveTheme();
52 /** @var \Drupal\Core\Theme\ActiveTheme $base_theme */
53 $base_themes = $theme->getBaseThemes();
54 $base_theme = reset($base_themes);
55 $this->assertTrue($base_theme->getName() == 'stable', "Stable theme is the base theme if a theme hasn't decided to opt out.");
59 * Tests opting out of Stable by setting the base theme to false.
61 public function testWildWest() {
62 $this->themeHandler->install(['test_wild_west']);
63 $this->config('system.theme')->set('default', 'test_wild_west')->save();
64 $theme = $this->themeManager->getActiveTheme();
65 /** @var \Drupal\Core\Theme\ActiveTheme $base_theme */
66 $base_themes = $theme->getBaseThemes();
67 $this->assertTrue(empty($base_themes), 'No base theme is set when a theme has opted out of using Stable.');