public function CspTest::testRemove in Content-Security-Policy 8
Test that removed directives are not output in the header.
@covers ::removeDirective @covers ::isValidDirectiveName @covers ::getHeaderValue
File
- tests/
src/ Unit/ CspTest.php, line 364
Class
- CspTest
- Test manipulating directives in a policy.
Namespace
Drupal\Tests\csp\UnitCode
public function testRemove() {
$policy = new Csp();
$policy
->setDirective('default-src', [
Csp::POLICY_SELF,
]);
$policy
->setDirective('script-src', 'example.com');
$policy
->removeDirective('script-src');
$this
->assertEquals("default-src 'self'", $policy
->getHeaderValue());
}