You are here

public function CoreCspSubscriberTest::testNoAttachments in Content-Security-Policy 8

Test a response with no attachments.

Classes like AjaxResponse may return an empty array, so an error shouldn't be thrown if the 'library' element does not exist.

@covers ::onCspPolicyAlter

File

tests/src/Unit/EventSubscriber/CoreCspSubscriberTest.php, line 88

Class

CoreCspSubscriberTest
@coversDefaultClass \Drupal\csp\EventSubscriber\CoreCspSubscriber @group csp

Namespace

Drupal\Tests\csp\Unit\EventSubscriber

Code

public function testNoAttachments() {
  $policy = new Csp();
  $this->response
    ->method('getAttachments')
    ->willReturn([]);
  $alterEvent = new PolicyAlterEvent($policy, $this->response);
  $this->coreCspSubscriber
    ->onCspPolicyAlter($alterEvent);
  $this
    ->addToAssertionCount(1);
}