@@ -37,6 +37,8 @@ public function testForCurrentUserUsesSessionUser(): void {
3737
3838 $ this ->userSession ->expects ($ this ->once ())->method ('getUser ' )->willReturn ($ user );
3939 $ this ->groupManager ->expects ($ this ->once ())->method ('getUserGroupIds ' )->with ($ user )->willReturn (['finance ' ]);
40+ $ this ->groupManager ->expects ($ this ->once ())->method ('isAdmin ' )->with ('john ' )->willReturn (false );
41+ $ this ->subAdmin ->expects ($ this ->once ())->method ('isSubAdmin ' )->with ($ user )->willReturn (false );
4042
4143 $ factory = $ this ->getFactory ();
4244 $ context = $ factory ->forCurrentUser (['signature_flow ' => 'parallel ' ], ['type ' => 'group ' , 'id ' => 'finance ' ]);
@@ -45,46 +47,6 @@ public function testForCurrentUserUsesSessionUser(): void {
4547 $ this ->assertSame (['finance ' ], $ context ->getGroups ());
4648 $ this ->assertSame (['signature_flow ' => 'parallel ' ], $ context ->getRequestOverrides ());
4749 $ this ->assertSame (['type ' => 'group ' , 'id ' => 'finance ' ], $ context ->getActiveContext ());
48- $ this ->assertSame ([
49- 'canManageSystemPolicies ' => false ,
50- 'canManageGroupPolicies ' => false ,
51- ], $ context ->getActorCapabilities ());
52- }
53-
54- public function testForCurrentUserMarksSystemAdminCapabilities (): void {
55- $ user = $ this ->createMock (IUser::class);
56- $ user ->method ('getUID ' )->willReturn ('admin ' );
57-
58- $ this ->userSession ->expects ($ this ->once ())->method ('getUser ' )->willReturn ($ user );
59- $ this ->groupManager ->expects ($ this ->once ())->method ('getUserGroupIds ' )->with ($ user )->willReturn ([]);
60- $ this ->groupManager ->expects ($ this ->once ())->method ('isAdmin ' )->with ('admin ' )->willReturn (true );
61- $ this ->subAdmin ->expects ($ this ->never ())->method ('isSubAdmin ' );
62-
63- $ factory = $ this ->getFactory ();
64- $ context = $ factory ->forCurrentUser ();
65-
66- $ this ->assertSame ([
67- 'canManageSystemPolicies ' => true ,
68- 'canManageGroupPolicies ' => true ,
69- ], $ context ->getActorCapabilities ());
70- }
71-
72- public function testForCurrentUserMarksSubAdminGroupCapabilities (): void {
73- $ user = $ this ->createMock (IUser::class);
74- $ user ->method ('getUID ' )->willReturn ('manager ' );
75-
76- $ this ->userSession ->expects ($ this ->once ())->method ('getUser ' )->willReturn ($ user );
77- $ this ->groupManager ->expects ($ this ->once ())->method ('getUserGroupIds ' )->with ($ user )->willReturn (['finance ' ]);
78- $ this ->groupManager ->expects ($ this ->once ())->method ('isAdmin ' )->with ('manager ' )->willReturn (false );
79- $ this ->subAdmin ->expects ($ this ->once ())->method ('isSubAdmin ' )->with ($ user )->willReturn (true );
80-
81- $ factory = $ this ->getFactory ();
82- $ context = $ factory ->forCurrentUser ();
83-
84- $ this ->assertSame ([
85- 'canManageSystemPolicies ' => false ,
86- 'canManageGroupPolicies ' => true ,
87- ], $ context ->getActorCapabilities ());
8850 }
8951
9052 public function testForUserIdLoadsUserWhenAvailable (): void {
0 commit comments