You are here

public function MenuRouterTest::testMaintenanceModeLoginPaths 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::testMaintenanceModeLoginPaths()

Make sure the maintenance mode can be bypassed using an EventSubscriber.

See also

\Drupal\menu_test\EventSubscriber\MaintenanceModeSubscriber::onKernelRequestMaintenance()

File

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

Class

MenuRouterTest
Tests menu router and default menu link functionality.

Namespace

Drupal\Tests\system\Functional\Menu

Code

public function testMaintenanceModeLoginPaths() {
  $this->container
    ->get('state')
    ->set('system.maintenance_mode', TRUE);
  $offline_message = $this
    ->config('system.site')
    ->get('name') . ' is currently under maintenance. We should be back shortly. Thank you for your patience.';
  $this
    ->drupalGet('test-page');
  $this
    ->assertSession()
    ->pageTextContains($offline_message);
  $this
    ->drupalGet('menu_login_callback');
  $this
    ->assertSession()
    ->pageTextContains('This is TestControllers::testLogin.');
  $this->container
    ->get('state')
    ->set('system.maintenance_mode', FALSE);
}