You are here

public function MaintenanceThemeTest::testMaintenanceTheme in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/KernelTests/Core/Theme/MaintenanceThemeTest.php \Drupal\KernelTests\Core\Theme\MaintenanceThemeTest::testMaintenanceTheme()

Tests that the maintenance theme initializes the theme and its base themes.

File

core/tests/Drupal/KernelTests/Core/Theme/MaintenanceThemeTest.php, line 22
Contains \Drupal\KernelTests\Core\Theme\MaintenanceThemeTest.

Class

MaintenanceThemeTest
Tests themes and base themes are correctly loaded.

Namespace

Drupal\KernelTests\Core\Theme

Code

public function testMaintenanceTheme() {
  $this
    ->setSetting('maintenance_theme', 'seven');

  // Get the maintenance theme loaded.
  drupal_maintenance_theme();

  // Do we have an active theme?
  $this
    ->assertTrue(\Drupal::theme()
    ->hasActiveTheme());
  $active_theme = \Drupal::theme()
    ->getActiveTheme();
  $this
    ->assertEquals('seven', $active_theme
    ->getName());
  $base_themes = $active_theme
    ->getBaseThemes();
  $base_theme_names = array_keys($base_themes);
  $this
    ->assertSame([
    'classy',
    'stable',
  ], $base_theme_names);

  // Ensure Classy has the correct base themes and amount of base themes.
  $classy_base_themes = $base_themes['classy']
    ->getBaseThemes();
  $classy_base_theme_names = array_keys($classy_base_themes);
  $this
    ->assertSame([
    'stable',
  ], $classy_base_theme_names);
}