Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / web / core / tests / Drupal / KernelTests / Core / Theme / StableThemeTest.php
1 <?php
2
3 namespace Drupal\KernelTests\Core\Theme;
4
5 use Drupal\KernelTests\KernelTestBase;
6
7 /**
8  * Tests the behavior of the Stable theme.
9  *
10  * @group Theme
11  */
12 class StableThemeTest extends KernelTestBase {
13
14   /**
15    * Modules to install.
16    *
17    * @var array
18    */
19   public static $modules = ['system'];
20
21   /**
22    * The theme handler.
23    *
24    * @var \Drupal\Core\Extension\ThemeHandlerInterface
25    */
26   protected $themeHandler;
27
28   /**
29    * The theme manager.
30    *
31    * @var \Drupal\Core\Theme\ThemeManagerInterface
32    */
33   protected $themeManager;
34
35   /**
36    * {@inheritdoc}
37    */
38   protected function setUp() {
39     parent::setUp();
40
41     $this->themeHandler = $this->container->get('theme_handler');
42     $this->themeManager = $this->container->get('theme.manager');
43   }
44
45   /**
46    * Ensures Stable is used by default when no base theme has been defined.
47    */
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.");
56   }
57
58   /**
59    * Tests opting out of Stable by setting the base theme to false.
60    */
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.');
68   }
69
70 }