function MenuRouterTest::testThemeCallbackMaintenanceMode

Test the theme callback when the site is in maintenance mode.

File

drupal/core/modules/system/lib/Drupal/system/Tests/Menu/MenuRouterTest.php, line 162
Definition of Drupal\system\Tests\Menu\MenuRouterTest.

Class

MenuRouterTest
Tests menu router and hook_menu() functionality.

Namespace

Drupal\system\Tests\Menu

Code

function testThemeCallbackMaintenanceMode() {
  config('system.maintenance')
    ->set('enabled', 1)
    ->save();
  theme_enable(array(
    $this->admin_theme,
  ));

  // 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/style.css', "The maintenance theme's CSS appears on the page.");

  // An administrator, however, should continue to see the requested theme.
  $admin_user = $this
    ->drupalCreateUser(array(
    'access site in maintenance mode',
  ));
  $this
    ->drupalLogin($admin_user);
  $this
    ->drupalGet('menu-test/theme-callback/use-admin-theme');
  $this
    ->assertText('Custom theme: seven. Actual theme: seven.', 'The theme callback system is correctly triggered for an administrator when the site is in maintenance mode.');
  $this
    ->assertRaw('seven/style.css', "The administrative theme's CSS appears on the page.");
  config('system.maintenance')
    ->set('enabled', 0)
    ->save();
}