You are here

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

Test that appending an empty value doesn't change the directive.

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

File

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

Class

CspTest
Test manipulating directives in a policy.

Namespace

Drupal\Tests\csp\Unit

Code

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