public function RemoveHttpHeadersTest::testRemoveNoHeaders in Remove HTTP headers 8
Ensure HTTP headers and meta are present when no removals configured.
@covers ::handle
File
- tests/
src/ Functional/ RemoveHttpHeadersTest.php, line 77
Class
- RemoveHttpHeadersTest
- Functional tests for Remove HTTP Headers module.
Namespace
Drupal\Tests\remove_http_headers\FunctionalCode
public function testRemoveNoHeaders() : void {
$form['headers_to_remove'] = '';
$this
->submitModuleSettingsForm($form);
// Verify config form reflects the change.
$this
->assertSession()
->fieldValueEquals('headers_to_remove', '');
// Verify saved configuration reflects the change.
$config = $this->configFactory
->get('remove_http_headers.settings')
->get('headers_to_remove');
$this
->assertEquals([], $config, 'The configuration option was properly saved.');
// Headers which we should expect Drupal to return.
$headersThatShouldExist = [
'X-Generator',
'X-Drupal-Cache-Tags',
'X-Drupal-Dynamic-Cache',
];
foreach ($headersThatShouldExist as $header) {
$this
->assertNotEmpty($this
->getSession()
->getResponseHeader($header), $this
->t('HTTP header @header is not present in response.', [
'@header' => $header,
])
->render());
}
// Default behaviour is to include meta name=Generator.
$this
->assertSession()
->responseContains(static::GENERATOR_METATAG_MARKUP);
}