Skip to content

Commit d333486

Browse files
committed
add failing test
1 parent ec3e054 commit d333486

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

Tests/Unit/Factory/PolicyFactoryTest.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,44 @@ public function testCreateShouldReturnPolicy(): void
5050

5151
self::assertSame($expected, $result->getDirectives());
5252
}
53+
54+
public function testCreateShouldAddDirectiveWhichIsPresentInCustomButNotDefaultConfiguration(): void
55+
{
56+
$policyFactory = new PolicyFactory();
57+
$nonceMock = $this->createMock(Nonce::class);
58+
59+
$defaultDirective = [
60+
'base-uri' => [
61+
'self',
62+
],
63+
'script-src' => [
64+
'self',
65+
],
66+
];
67+
$customDirective = [
68+
'script-src' => [
69+
'{nonce}',
70+
],
71+
'worker-src' => [
72+
'self',
73+
],
74+
];
75+
76+
$expected = [
77+
'base-uri' => [
78+
"'self'",
79+
],
80+
'script-src' => [
81+
"'self'",
82+
"'nonce-'",
83+
],
84+
'worker-src' => [
85+
'self',
86+
],
87+
];
88+
89+
$result = $policyFactory->create($nonceMock, $defaultDirective, $customDirective);
90+
91+
self::assertSame($expected, $result->getDirectives());
92+
}
5393
}

0 commit comments

Comments
 (0)