function MenuRouterTest::testMaintenanceModeLoginPaths

Same name in other branches
  1. 9 core/modules/system/tests/src/Functional/Menu/MenuRouterTest.php \Drupal\Tests\system\Functional\Menu\MenuRouterTest::testMaintenanceModeLoginPaths()
  2. 8.9.x core/modules/system/tests/src/Functional/Menu/MenuRouterTest.php \Drupal\Tests\system\Functional\Menu\MenuRouterTest::testMaintenanceModeLoginPaths()
  3. 11.x 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 214

Class

MenuRouterTest
Tests menu router and default menu link functionality.

Namespace

Drupal\Tests\system\Functional\Menu

Code

public function testMaintenanceModeLoginPaths() : void {
    $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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.