You are here

protected function MenuRouterTest::doTestThemeCallbackMaintenanceMode in Drupal 9

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()

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('bartik/css/base/elements.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: seven. Actual theme: seven.');

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