function MenuRouterTest::doTestThemeCallbackOptionalTheme

Same name in other branches
  1. 9 core/modules/system/tests/src/Functional/Menu/MenuRouterTest.php \Drupal\Tests\system\Functional\Menu\MenuRouterTest::doTestThemeCallbackOptionalTheme()
  2. 8.9.x core/modules/system/tests/src/Functional/Menu/MenuRouterTest.php \Drupal\Tests\system\Functional\Menu\MenuRouterTest::doTestThemeCallbackOptionalTheme()
  3. 10 core/modules/system/tests/src/Functional/Menu/MenuRouterTest.php \Drupal\Tests\system\Functional\Menu\MenuRouterTest::doTestThemeCallbackOptionalTheme()

Tests the theme negotiation when it is set to use an optional theme.

1 call to MenuRouterTest::doTestThemeCallbackOptionalTheme()
MenuRouterTest::testThemeIntegration in core/modules/system/tests/src/Functional/Menu/MenuRouterTest.php
Tests theme integration.

File

core/modules/system/tests/src/Functional/Menu/MenuRouterTest.php, line 306

Class

MenuRouterTest
Tests menu router and default menu link functionality.

Namespace

Drupal\Tests\system\Functional\Menu

Code

protected function doTestThemeCallbackOptionalTheme() : void {
    // Request a theme that is not installed.
    $this->drupalGet('menu-test/theme-callback/use-test-theme');
    $this->assertSession()
        ->pageTextContains('Active theme: olivero. Actual theme: olivero.');
    // Check that the default theme's CSS appears on the page.
    $this->assertSession()
        ->responseContains('olivero/css/base/base.css');
    // Now install the theme and request it again.
    
    /** @var \Drupal\Core\Extension\ThemeInstallerInterface $theme_installer */
    $theme_installer = $this->container
        ->get('theme_installer');
    $theme_installer->install([
        'test_theme',
    ]);
    $this->drupalGet('menu-test/theme-callback/use-test-theme');
    $this->assertSession()
        ->pageTextContains('Active theme: test_theme. Actual theme: test_theme.');
    // Check that the optional theme's CSS appears on the page.
    $this->assertSession()
        ->responseContains('test_theme/kitten.css');
    $theme_installer->uninstall([
        'test_theme',
    ]);
}

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