|
24 | 24 | use DateTimeZone; |
25 | 25 | use PHPUnit\Framework\Attributes\DataProvider; |
26 | 26 | use PHPUnit\Framework\Attributes\Group; |
27 | | -use ReflectionClass; |
28 | 27 |
|
29 | 28 | /** |
30 | 29 | * @internal |
@@ -612,14 +611,11 @@ public function testSendRemovesCustomNoncePlaceholdersWhenCSPDisabled(): void |
612 | 611 | $cspConfig->scriptNonceTag = '{custom-script-tag}'; |
613 | 612 | $cspConfig->styleNonceTag = '{custom-style-tag}'; |
614 | 613 |
|
| 614 | + Services::injectMock('csp', new ContentSecurityPolicy($cspConfig)); |
| 615 | + |
615 | 616 | $response = new Response($appConfig); |
616 | 617 | $response->pretend(true); |
617 | 618 |
|
618 | | - // Inject the custom CSP config |
619 | | - $reflection = new ReflectionClass($response); |
620 | | - $cspProperty = $reflection->getProperty('CSP'); |
621 | | - $cspProperty->setValue($response, new ContentSecurityPolicy($cspConfig)); |
622 | | - |
623 | 619 | $body = '<html><script {custom-script-tag}>test()</script><style {custom-style-tag}>.x{}</style></html>'; |
624 | 620 | $response->setBody($body); |
625 | 621 |
|
@@ -708,14 +704,11 @@ public function testSendRemovesPlaceholdersWhenBothCSPAndAutoNonceAreDisabled(): |
708 | 704 | $cspConfig = new \Config\ContentSecurityPolicy(); |
709 | 705 | $cspConfig->autoNonce = false; |
710 | 706 |
|
| 707 | + Services::injectMock('csp', new ContentSecurityPolicy($cspConfig)); |
| 708 | + |
711 | 709 | $response = new Response($appConfig); |
712 | 710 | $response->pretend(true); |
713 | 711 |
|
714 | | - // Inject the custom CSP config |
715 | | - $reflection = new ReflectionClass($response); |
716 | | - $cspProperty = $reflection->getProperty('CSP'); |
717 | | - $cspProperty->setValue($response, new ContentSecurityPolicy($cspConfig)); |
718 | | - |
719 | 712 | $body = '<html><script {csp-script-nonce}>test()</script><style {csp-style-nonce}>.x{}</style></html>'; |
720 | 713 | $response->setBody($body); |
721 | 714 |
|
|
0 commit comments