public function RemoveHttpHeadersTest::testRemoveSomeHeaders in Remove HTTP headers 8
Ensure default HTTP headers and meta are removed when configured.
@covers ::handle
File
- tests/
src/ Functional/ RemoveHttpHeadersTest.php, line 110
Class
- RemoveHttpHeadersTest
- Functional tests for Remove HTTP Headers module.
Namespace
Drupal\Tests\remove_http_headers\FunctionalCode
public function testRemoveSomeHeaders() : void {
$headersToRemove = [
'X-Generator',
'X-Drupal-Cache-Tags',
'X-Drupal-Dynamic-Cache',
];
$form['headers_to_remove'] = implode("\n", $headersToRemove);
$this
->submitModuleSettingsForm($form);
// Verify config form reflects the change.
$this
->assertSession()
->fieldValueEquals('headers_to_remove', implode("\n", $headersToRemove));
// Verify saved configuration reflects the change.
$config = $this->configFactory
->get('remove_http_headers.settings')
->get('headers_to_remove');
$this
->assertEquals($headersToRemove, $config, 'The configuration option was properly saved.');
foreach ($headersToRemove as $header) {
$this
->assertEmpty($this
->getSession()
->getResponseHeader($header), $this
->t('HTTP header @header is not present in response.', [
'@header' => $header,
])
->render());
}
// X-Generator is set, so meta name=Generator should not be present.
$this
->assertSession()
->responseNotContains(static::GENERATOR_METATAG_MARKUP);
}