1717use OCA \Libresign \Service \Policy \Runtime \PolicyContextFactory ;
1818use OCA \Libresign \Service \Policy \Runtime \PolicyRegistry ;
1919use OCA \Libresign \Service \Policy \Runtime \PolicySource ;
20+ use OCP \Group \ISubAdmin ;
2021use OCP \IGroupManager ;
2122use OCP \IL10N ;
2223use OCP \IUser ;
2930final class PolicyServiceTest extends TestCase {
3031 private IUserManager &MockObject $ userManager ;
3132 private IGroupManager &MockObject $ groupManager ;
33+ private ISubAdmin &MockObject $ subAdmin ;
3234 private IUserSession &MockObject $ userSession ;
3335 private PolicySource &MockObject $ source ;
3436 private IL10N &MockObject $ l10n ;
@@ -39,6 +41,7 @@ protected function setUp(): void {
3941 parent ::setUp ();
4042 $ this ->userManager = $ this ->createMock (IUserManager::class);
4143 $ this ->groupManager = $ this ->createMock (IGroupManager::class);
44+ $ this ->subAdmin = $ this ->createMock (ISubAdmin::class);
4245 $ this ->userSession = $ this ->createMock (IUserSession::class);
4346 $ this ->source = $ this ->createMock (PolicySource::class);
4447 $ this ->l10n = $ this ->createMock (IL10N ::class);
@@ -61,7 +64,7 @@ protected function setUp(): void {
6164 };
6265 });
6366 $ this ->registry = new PolicyRegistry ($ container );
64- $ this ->contextFactory = new PolicyContextFactory ($ this ->userManager , $ this ->groupManager , $ this ->userSession );
67+ $ this ->contextFactory = new PolicyContextFactory ($ this ->userManager , $ this ->groupManager , $ this ->subAdmin , $ this -> userSession );
6568 }
6669
6770 public function testResolveForUserIdUsesDocMdpGroupPolicyWhenSystemAllowsOverride (): void {
@@ -351,7 +354,6 @@ public function testSaveUserPreferenceForUserIdAllowsSystemAdminBypassWhenGroupB
351354 ->willReturn (['finance ' ]);
352355
353356 $ this ->groupManager
354- ->expects ($ this ->once ())
355357 ->method ('isAdmin ' )
356358 ->with ('admin ' )
357359 ->willReturn (true );
@@ -428,7 +430,6 @@ public function testSaveUserPreferenceForUserIdBlocksNonAdminWhenGroupDisallowsU
428430 ->willReturn (['finance ' ]);
429431
430432 $ this ->groupManager
431- ->expects ($ this ->once ())
432433 ->method ('isAdmin ' )
433434 ->with ('manager ' )
434435 ->willReturn (false );
0 commit comments