You are here

public function CspTest::testAppendMultiple in Content-Security-Policy 8

Test that appending to a directive extends the existing value.

@covers ::appendDirective @covers ::isValidDirectiveName @covers ::getHeaderValue

File

tests/src/Unit/CspTest.php, line 196

Class

CspTest
Test manipulating directives in a policy.

Namespace

Drupal\Tests\csp\Unit

Code

public function testAppendMultiple() {
  $policy = new Csp();
  $policy
    ->appendDirective('default-src', Csp::POLICY_SELF);
  $policy
    ->appendDirective('script-src', [
    Csp::POLICY_SELF,
    'two.example.com',
  ]);
  $policy
    ->appendDirective('default-src', 'one.example.com');
  $this
    ->assertEquals("default-src 'self' one.example.com; script-src 'self' two.example.com", $policy
    ->getHeaderValue());
}