@@ -63,7 +63,7 @@ public function testLoadSystemPolicyReturnsForcedLayerWhenAppConfigIsSet(): void
6363 $ layer = $ source ->loadSystemPolicy ('signature_flow ' );
6464
6565 $ this ->assertNotNull ($ layer );
66- $ this ->assertSame ('system ' , $ layer ->getScope ());
66+ $ this ->assertSame ('global ' , $ layer ->getScope ());
6767 $ this ->assertSame ('ordered_numeric ' , $ layer ->getValue ());
6868 $ this ->assertFalse ($ layer ->isAllowChildOverride ());
6969 $ this ->assertSame (['ordered_numeric ' ], $ layer ->getAllowedValues ());
@@ -82,6 +82,7 @@ public function testLoadSystemPolicyReturnsInheritableLayerWhenAppConfigMatchesD
8282
8383 $ this ->assertNotNull ($ layer );
8484 $ this ->assertSame ('none ' , $ layer ->getValue ());
85+ $ this ->assertSame ('system ' , $ layer ->getScope ());
8586 $ this ->assertTrue ($ layer ->isAllowChildOverride ());
8687 $ this ->assertSame ([], $ layer ->getAllowedValues ());
8788 }
@@ -180,6 +181,29 @@ public function testSaveSystemPolicyDeletesAppConfigWhenValueMatchesDefault(): v
180181 $ this ->assertSame (['policy.signature_flow.system ' , 'policy.signature_flow.system.allow_child_override ' ], $ deletedKeys );
181182 }
182183
184+ public function testSaveSystemPolicyPersistsExplicitDefaultWhenAllowChildOverrideIsTrue (): void {
185+ $ savedValues = [];
186+ $ this ->appConfig
187+ ->expects ($ this ->exactly (2 ))
188+ ->method ('setAppValueString ' )
189+ ->willReturnCallback (static function (string $ key , string $ value ) use (&$ savedValues ): bool {
190+ $ savedValues [$ key ] = $ value ;
191+ return true ;
192+ });
193+
194+ $ this ->appConfig
195+ ->expects ($ this ->never ())
196+ ->method ('deleteAppValue ' );
197+
198+ $ source = $ this ->getSource ();
199+ $ source ->saveSystemPolicy ('signature_flow ' , 'none ' , true );
200+
201+ $ this ->assertSame ([
202+ 'policy.signature_flow.system ' => 'none ' ,
203+ 'policy.signature_flow.system.allow_child_override ' => '1 ' ,
204+ ], $ savedValues );
205+ }
206+
183207 public function testSaveSystemPolicyNormalizesAndPersistsAppConfigValue (): void {
184208 $ savedValues = [];
185209 $ this ->appConfig
@@ -222,11 +246,38 @@ public function testLoadSystemPolicyRespectsPersistedAllowChildOverride(): void
222246
223247 $ this ->assertNotNull ($ layer );
224248 $ this ->assertSame ('ordered_numeric ' , $ layer ->getValue ());
249+ $ this ->assertSame ('global ' , $ layer ->getScope ());
225250 $ this ->assertTrue ($ layer ->isAllowChildOverride ());
226251 $ this ->assertSame ([], $ layer ->getAllowedValues ());
227252 $ this ->assertSame (2 , $ calls );
228253 }
229254
255+ public function testLoadSystemPolicyTreatsPersistedDefaultAsExplicitWhenAllowChildOverrideIsSet (): void {
256+ $ this ->appConfig
257+ ->expects ($ this ->exactly (2 ))
258+ ->method ('getAppValueString ' )
259+ ->willReturnCallback (static function (string $ key , string $ default ): string {
260+ if ($ key === 'policy.signature_flow.system ' && $ default === '' ) {
261+ return 'none ' ;
262+ }
263+
264+ if ($ key === 'policy.signature_flow.system.allow_child_override ' && $ default === '0 ' ) {
265+ return '1 ' ;
266+ }
267+
268+ throw new \RuntimeException ('Unexpected app config key request: ' . $ key );
269+ });
270+
271+ $ source = $ this ->getSource ();
272+ $ layer = $ source ->loadSystemPolicy ('signature_flow ' );
273+
274+ $ this ->assertNotNull ($ layer );
275+ $ this ->assertSame ('none ' , $ layer ->getValue ());
276+ $ this ->assertSame ('global ' , $ layer ->getScope ());
277+ $ this ->assertTrue ($ layer ->isAllowChildOverride ());
278+ $ this ->assertSame ([], $ layer ->getAllowedValues ());
279+ }
280+
230281 public function testLoadGroupPolicyConfigReturnsBoundPolicyLayer (): void {
231282 $ binding = new PermissionSetBinding ();
232283 $ binding ->setPermissionSetId (77 );
0 commit comments