File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -402,6 +402,22 @@ public function enabled(): bool
402402 return $ this ->CSPEnabled ;
403403 }
404404
405+ /**
406+ * Enable Content Security Policy enforcement.
407+ */
408+ public function enable (): void
409+ {
410+ $ this ->CSPEnabled = true ;
411+ }
412+
413+ /**
414+ * Disable Content Security Policy enforcement.
415+ */
416+ public function disable (): void
417+ {
418+ $ this ->CSPEnabled = false ;
419+ }
420+
405421 /**
406422 * Whether adding nonce in style-* directives is enabled or not.
407423 */
Original file line number Diff line number Diff line change @@ -91,6 +91,26 @@ public function testExistence(): void
9191 $ this ->assertHeaderEmitted ('Content-Security-Policy: ' );
9292 }
9393
94+ #[PreserveGlobalState(false )]
95+ #[RunInSeparateProcess]
96+ public function testDisable (): void
97+ {
98+ $ this ->prepare (true );
99+ $ this ->csp ->disable ();
100+ $ this ->assertTrue ($ this ->work ());
101+ $ this ->assertHeaderNotEmitted ('Content-Security-Policy: ' );
102+ }
103+
104+ #[PreserveGlobalState(false )]
105+ #[RunInSeparateProcess]
106+ public function testEnable (): void
107+ {
108+ $ this ->prepare (false );
109+ $ this ->csp ->enable ();
110+ $ this ->assertTrue ($ this ->work ());
111+ $ this ->assertHeaderEmitted ('Content-Security-Policy: ' );
112+ }
113+
94114 #[PreserveGlobalState(false )]
95115 #[RunInSeparateProcess]
96116 public function testReportOnly (): void
You can’t perform that action at this time.
0 commit comments