File tree Expand file tree Collapse file tree
tests/php/Unit/Service/Policy/Runtime Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -342,6 +342,29 @@ public function testResolveCanSaveAsUserDefaultFalseWhenDefinitionDoesNotSupport
342342 $ this ->assertFalse ($ resolved ->canUseAsRequestOverride ());
343343 }
344344
345+ public function testResolveHidesWhenUserIsNotEligible (): void {
346+ $ source = new InMemoryPolicySource ();
347+ $ source ->systemLayer = (new PolicyLayer ())
348+ ->setScope ('system ' )
349+ ->setValue ('none ' )
350+ ->setAllowChildOverride (true )
351+ ->setVisibleToChild (true );
352+
353+ $ definition = new PolicySpec (
354+ key: 'context_only_policy ' ,
355+ defaultSystemValue: 'none ' ,
356+ allowedValues: ['none ' , 'strict ' ],
357+ eligibilityChecker: static fn (PolicyContext $ ctx ): bool => false ,
358+ );
359+
360+ $ resolver = new DefaultPolicyResolver ($ source );
361+ $ resolved = $ resolver ->resolve ($ definition , PolicyContext::fromUserId ('john ' ));
362+
363+ $ this ->assertFalse ($ resolved ->isVisible (), 'Policy must be hidden when user is not eligible ' );
364+ $ this ->assertFalse ($ resolved ->canSaveAsUserDefault ());
365+ $ this ->assertFalse ($ resolved ->canUseAsRequestOverride ());
366+ }
367+
345368 private function getValueChoiceDefinition (): PolicySpec {
346369 return new PolicySpec (
347370 key: 'signature_flow ' ,
You can’t perform that action at this time.
0 commit comments