function SiteMaintenanceTest::testNonHtmlRequest
Same name in other branches
- 9 core/modules/system/tests/src/Functional/System/SiteMaintenanceTest.php \Drupal\Tests\system\Functional\System\SiteMaintenanceTest::testNonHtmlRequest()
- 10 core/modules/system/tests/src/Functional/System/SiteMaintenanceTest.php \Drupal\Tests\system\Functional\System\SiteMaintenanceTest::testNonHtmlRequest()
- 11.x core/modules/system/tests/src/Functional/System/SiteMaintenanceTest.php \Drupal\Tests\system\Functional\System\SiteMaintenanceTest::testNonHtmlRequest()
Tests responses to non-HTML requests when in maintenance mode.
File
-
core/
modules/ system/ tests/ src/ Functional/ System/ SiteMaintenanceTest.php, line 159
Class
- SiteMaintenanceTest
- Tests access to site while in maintenance mode.
Namespace
Drupal\Tests\system\Functional\SystemCode
public function testNonHtmlRequest() {
$this->drupalLogout();
\Drupal::state()->set('system.maintenance_mode', TRUE);
$formats = [
'json',
'xml',
'non-existing',
];
foreach ($formats as $format) {
$this->drupalGet('<front>', [
'query' => [
'_format' => $format,
],
]);
$this->assertSession()
->statusCodeEquals(503);
$this->assertRaw('Drupal is currently under maintenance. We should be back shortly. Thank you for your patience.');
$this->assertSession()
->responseHeaderEquals('Content-Type', 'text/plain; charset=UTF-8');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.