You are here

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

Test that changing the policy's report-only flag updates the header name.

@covers ::reportOnly @covers ::isReportOnly @covers ::getHeaderName

File

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

Class

CspTest
Test manipulating directives in a policy.

Namespace

Drupal\Tests\csp\Unit

Code

public function testReportOnly() {
  $policy = new Csp();
  $this
    ->assertFalse($policy
    ->isReportOnly());
  $this
    ->assertEquals("Content-Security-Policy", $policy
    ->getHeaderName());
  $policy
    ->reportOnly();
  $this
    ->assertTrue($policy
    ->isReportOnly());
  $this
    ->assertEquals("Content-Security-Policy-Report-Only", $policy
    ->getHeaderName());
  $policy
    ->reportOnly(FALSE);
  $this
    ->assertFalse($policy
    ->isReportOnly());
  $this
    ->assertEquals("Content-Security-Policy", $policy
    ->getHeaderName());
}