You are here

protected function MenuRouterTest::doTestThemeCallbackMaintenanceMode in Drupal 8

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

Test 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');
  $this
    ->assertRaw('bartik/css/base/elements.css', "The maintenance theme's CSS appears on the page.");

  // 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
    ->assertText('Active theme: seven. Actual theme: seven.', 'The theme negotiation system is correctly triggered for an administrator when the site is in maintenance mode.');
  $this
    ->assertRaw('seven/css/base/elements.css', "The administrative theme's CSS appears on the page.");
  $this->container
    ->get('state')
    ->set('system.maintenance_mode', FALSE);
}