2323use OCP \AppFramework \Http \DataResponse ;
2424use OCP \AppFramework \OCS \OCSException ;
2525use OCP \EventDispatcher \IEventDispatcher ;
26+ use OCP \Group \ISubAdmin ;
2627use OCP \IConfig ;
2728use OCP \IGroup ;
2829use OCP \IL10N ;
@@ -57,6 +58,8 @@ class UsersControllerTest extends TestCase {
5758 protected $ api ;
5859 /** @var IAccountManager|MockObject */
5960 protected $ accountManager ;
61+ /** @var ISubAdmin|MockObject */
62+ protected $ subAdminManager ;
6063 /** @var IURLGenerator|MockObject */
6164 protected $ urlGenerator ;
6265 /** @var IRequest|MockObject */
@@ -86,6 +89,7 @@ protected function setUp(): void {
8689 $ this ->logger = $ this ->createMock (LoggerInterface::class);
8790 $ this ->request = $ this ->createMock (IRequest::class);
8891 $ this ->accountManager = $ this ->createMock (IAccountManager::class);
92+ $ this ->subAdminManager = $ this ->createMock (ISubAdmin::class);
8993 $ this ->urlGenerator = $ this ->createMock (IURLGenerator::class);
9094 $ this ->l10nFactory = $ this ->createMock (IFactory::class);
9195 $ this ->newUserMailHelper = $ this ->createMock (NewUserMailHelper::class);
@@ -108,6 +112,7 @@ protected function setUp(): void {
108112 $ this ->groupManager ,
109113 $ this ->userSession ,
110114 $ this ->accountManager ,
115+ $ this ->subAdminManager ,
111116 $ this ->l10nFactory ,
112117 $ this ->urlGenerator ,
113118 $ this ->logger ,
@@ -376,6 +381,7 @@ public function testAddUserSuccessfulWithDisplayName(): void {
376381 $ this ->groupManager ,
377382 $ this ->userSession ,
378383 $ this ->accountManager ,
384+ $ this ->subAdminManager ,
379385 $ this ->l10nFactory ,
380386 $ this ->urlGenerator ,
381387 $ this ->logger ,
@@ -931,7 +937,6 @@ public function testGetUserDataAsAdmin(): void {
931937 ->disableOriginalConstructor ()
932938 ->getMock ();
933939 $ loggedInUser
934- ->expects ($ this ->exactly (2 ))
935940 ->method ('getUID ' )
936941 ->willReturn ('admin ' );
937942 $ targetUser = $ this ->getMockBuilder (IUser::class)
@@ -941,16 +946,13 @@ public function testGetUserDataAsAdmin(): void {
941946 ->method ('getSystemEMailAddress ' )
942947 ->willReturn ('demo@nextcloud.com ' );
943948 $ this ->userSession
944- ->expects ($ this ->once ())
945949 ->method ('getUser ' )
946950 ->willReturn ($ loggedInUser );
947951 $ this ->userManager
948- ->expects ($ this ->exactly (2 ))
949952 ->method ('get ' )
950953 ->with ('UID ' )
951954 ->willReturn ($ targetUser );
952955 $ this ->groupManager
953- ->expects ($ this ->once ())
954956 ->method ('isAdmin ' )
955957 ->with ('admin ' )
956958 ->willReturn (true );
@@ -1079,7 +1081,6 @@ public function testGetUserDataAsSubAdminAndUserIsAccessible(): void {
10791081 ->disableOriginalConstructor ()
10801082 ->getMock ();
10811083 $ loggedInUser
1082- ->expects ($ this ->exactly (2 ))
10831084 ->method ('getUID ' )
10841085 ->willReturn ('subadmin ' );
10851086 $ targetUser = $ this ->getMockBuilder (IUser::class)
@@ -1090,16 +1091,13 @@ public function testGetUserDataAsSubAdminAndUserIsAccessible(): void {
10901091 ->method ('getSystemEMailAddress ' )
10911092 ->willReturn ('demo@nextcloud.com ' );
10921093 $ this ->userSession
1093- ->expects ($ this ->once ())
10941094 ->method ('getUser ' )
10951095 ->willReturn ($ loggedInUser );
10961096 $ this ->userManager
1097- ->expects ($ this ->exactly (2 ))
10981097 ->method ('get ' )
10991098 ->with ('UID ' )
11001099 ->willReturn ($ targetUser );
11011100 $ this ->groupManager
1102- ->expects ($ this ->once ())
11031101 ->method ('isAdmin ' )
11041102 ->with ('subadmin ' )
11051103 ->willReturn (false );
@@ -1267,23 +1265,19 @@ public function testGetUserDataAsSubAdminSelfLookup(): void {
12671265 ->disableOriginalConstructor ()
12681266 ->getMock ();
12691267 $ loggedInUser
1270- ->expects ($ this ->exactly (3 ))
12711268 ->method ('getUID ' )
12721269 ->willReturn ('UID ' );
12731270 $ targetUser = $ this ->getMockBuilder (IUser::class)
12741271 ->disableOriginalConstructor ()
12751272 ->getMock ();
12761273 $ this ->userSession
1277- ->expects ($ this ->once ())
12781274 ->method ('getUser ' )
12791275 ->willReturn ($ loggedInUser );
12801276 $ this ->userManager
1281- ->expects ($ this ->exactly (2 ))
12821277 ->method ('get ' )
12831278 ->with ('UID ' )
12841279 ->willReturn ($ targetUser );
12851280 $ this ->groupManager
1286- ->expects ($ this ->once ())
12871281 ->method ('isAdmin ' )
12881282 ->with ('UID ' )
12891283 ->willReturn (false );
@@ -3667,6 +3661,7 @@ public function testGetCurrentUserLoggedIn(): void {
36673661 $ this ->groupManager ,
36683662 $ this ->userSession ,
36693663 $ this ->accountManager ,
3664+ $ this ->subAdminManager ,
36703665 $ this ->l10nFactory ,
36713666 $ this ->urlGenerator ,
36723667 $ this ->logger ,
@@ -3756,6 +3751,7 @@ public function testGetUser(): void {
37563751 $ this ->groupManager ,
37573752 $ this ->userSession ,
37583753 $ this ->accountManager ,
3754+ $ this ->subAdminManager ,
37593755 $ this ->l10nFactory ,
37603756 $ this ->urlGenerator ,
37613757 $ this ->logger ,
0 commit comments