public function Ie9CspSubscriberTest::testNoDirectives in Content-Security-Policy 8
Shouldn't alter the policy if no directives are enabled.
@covers ::onCspPolicyAlter
File
- tests/
src/ Unit/ EventSubscriber/ Ie9CspSubscriberTest.php, line 63
Class
- Ie9CspSubscriberTest
- @coversDefaultClass \Drupal\csp\EventSubscriber\Ie9CspSubscriber @group csp
Namespace
Drupal\Tests\csp\Unit\EventSubscriberCode
public function testNoDirectives() {
$this->moduleHandler
->method('moduleExists')
->willReturn($this
->callback(function ($parameter) {
return $parameter === 'ie9';
}));
/** @var \Drupal\Core\Config\ConfigFactoryInterface|\PHPUnit_Framework_MockObject_MockObject $configFactory */
$configFactory = $this
->getConfigFactoryStub([
'system.performance' => [
'css.preprocess' => FALSE,
],
]);
$policy = new Csp();
$alterEvent = new PolicyAlterEvent($policy, $this->response);
$subscriber = new Ie9CspSubscriber($configFactory, $this->moduleHandler);
$subscriber
->onCspPolicyAlter($alterEvent);
$this
->assertFalse($alterEvent
->getPolicy()
->hasDirective('script-src'));
$this
->assertFalse($alterEvent
->getPolicy()
->hasDirective('script-src-attr'));
$this
->assertFalse($alterEvent
->getPolicy()
->hasDirective('script-src-elem'));
}