You are here

protected function MenuRouterTest::doTestThemeCallbackMaintenanceMode in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/system/tests/src/Functional/Menu/MenuRouterTest.php \Drupal\Tests\system\Functional\Menu\MenuRouterTest::doTestThemeCallbackMaintenanceMode()
  2. 9 core/modules/system/tests/src/Functional/Menu/MenuRouterTest.php \Drupal\Tests\system\Functional\Menu\MenuRouterTest::doTestThemeCallbackMaintenanceMode()

Tests the theme negotiation when the site is in maintenance mode.

1 call to MenuRouterTest::doTestThemeCallbackMaintenanceMode()
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 279

Class

MenuRouterTest
Tests menu router and default menu link functionality.

Namespace

Drupal\Tests\system\Functional\Menu

Code

protected function doTestThemeCallbackMaintenanceMode() {
  $this->container
    ->get('state')
    ->set('system.maintenance_mode', TRUE);

  // For a regular user, the fact that the site is in maintenance mode means
  // we expect the theme callback system to be bypassed entirely.
  $this
    ->drupalGet('menu-test/theme-callback/use-admin-theme');

  // Check that the maintenance theme's CSS appears on the page.
  $this
    ->assertSession()
    ->responseContains('olivero/css/base/base.css');

  // An administrator, however, should continue to see the requested theme.
  $admin_user = $this
    ->drupalCreateUser([
    'access site in maintenance mode',
  ]);
  $this
    ->drupalLogin($admin_user);
  $this
    ->drupalGet('menu-test/theme-callback/use-admin-theme');
  $this
    ->assertSession()
    ->pageTextContains('Active theme: claro. Actual theme: claro.');

  // Check that the administrative theme's CSS appears on the page.
  $this
    ->assertSession()
    ->responseContains('claro/css/base/elements.css');
  $this->container
    ->get('state')
    ->set('system.maintenance_mode', FALSE);
}