You are here

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

Test appending a single value to an uninitialized directive.

@covers ::appendDirective @covers ::hasDirective @covers ::getDirective @covers ::isValidDirectiveName @covers ::validateDirectiveName @covers ::getHeaderValue

File

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

Class

CspTest
Test manipulating directives in a policy.

Namespace

Drupal\Tests\csp\Unit

Code

public function testAppendSingle() {
  $policy = new Csp();
  $policy
    ->appendDirective('default-src', Csp::POLICY_SELF);
  $this
    ->assertTrue($policy
    ->hasDirective('default-src'));
  $this
    ->assertEquals($policy
    ->getDirective('default-src'), [
    "'self'",
  ]);
  $this
    ->assertEquals("default-src 'self'", $policy
    ->getHeaderValue());
}