public function CoreCspSubscriberTest::testUmamiFontDefaultFallback in Content-Security-Policy 8
Test font-src fallback if default-src enabled.
@covers ::onCspPolicyAlter
File
- tests/
src/ Unit/ EventSubscriber/ CoreCspSubscriberTest.php, line 369
Class
- CoreCspSubscriberTest
- @coversDefaultClass \Drupal\csp\EventSubscriber\CoreCspSubscriber @group csp
Namespace
Drupal\Tests\csp\Unit\EventSubscriberCode
public function testUmamiFontDefaultFallback() {
$policy = new Csp();
$policy
->setDirective('default-src', [
Csp::POLICY_SELF,
]);
$this->response
->method('getAttachments')
->willReturn([
'library' => [
'umami/webfonts',
],
]);
$alterEvent = new PolicyAlterEvent($policy, $this->response);
$this->coreCspSubscriber
->onCspPolicyAlter($alterEvent);
$this
->assertEquals([
Csp::POLICY_SELF,
'https://fonts.gstatic.com',
], $alterEvent
->getPolicy()
->getDirective('font-src'));
}