function ActiveThemeLegacyTest::testGetBaseThemes

Tests \Drupal\Core\Theme\ActiveTheme::getBaseThemes() deprecation.

@covers ::getBaseThemes @expectedDeprecation \Drupal\Core\Theme\ActiveTheme::getBaseThemes() is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Use \Drupal\Core\Theme\ActiveTheme::getBaseThemeExtensions() instead. See https://www.drupal.org/node/3019948

File

core/tests/Drupal/KernelTests/Core/Theme/ActiveThemeLegacyTest.php, line 28

Class

ActiveThemeLegacyTest
Tests legacy code in ActiveTheme.

Namespace

Drupal\KernelTests\Core\Theme

Code

public function testGetBaseThemes() {
    $this->container
        ->get('theme_installer')
        ->install([
        'test_subsubtheme',
    ]);
    $this->config('system.theme')
        ->set('default', 'test_subsubtheme')
        ->save();
    $active_theme = \Drupal::theme()->getActiveTheme();
    // Ensure that active theme representations of base themes can be retrieved.
    $base_themes = $active_theme->getBaseThemes();
    $this->assertInstanceOf(ActiveTheme::class, $base_themes['test_subtheme']);
    $this->assertSame([
        'test_subtheme',
        'test_basetheme',
    ], array_keys($base_themes));
    // Ensure that we can get base themes from base themes.
    $test_subtheme_base_themes = $base_themes['test_subtheme']->getBaseThemes();
    $this->assertSame([
        'test_basetheme',
    ], array_keys($test_subtheme_base_themes));
    $this->assertEmpty($test_subtheme_base_themes['test_basetheme']->getBaseThemes());
}

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