public function SiteMaintenanceTest::testNonHtmlRequest in Drupal 9
Same name and namespace in other branches
- 8 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 162
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
->assertSession()
->pageTextContains('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');
}
}