88
99namespace OCA \Provisioning_API \Tests \Controller ;
1010
11+ use OC \Group \DisplayNameCache as GroupDisplayNameCache ;
1112use OC \Group \Manager ;
1213use OCA \Provisioning_API \Controller \GroupsController ;
1314use OCP \Accounts \IAccountManager ;
@@ -37,6 +38,7 @@ class GroupsControllerTest extends \Test\TestCase {
3738 protected IFactory &MockObject $ l10nFactory ;
3839 protected LoggerInterface &MockObject $ logger ;
3940 protected GroupsController &MockObject $ api ;
41+ private GroupDisplayNameCache &MockObject $ groupDisplayNameCache ;
4042
4143 private IRootFolder $ rootFolder ;
4244
@@ -53,6 +55,7 @@ protected function setUp(): void {
5355 $ this ->l10nFactory = $ this ->createMock (IFactory::class);
5456 $ this ->logger = $ this ->createMock (LoggerInterface::class);
5557 $ this ->rootFolder = $ this ->createMock (IRootFolder::class);
58+ $ this ->groupDisplayNameCache = $ this ->createMock (GroupDisplayNameCache::class);
5659
5760 $ this ->groupManager
5861 ->method ('getSubAdmin ' )
@@ -70,7 +73,8 @@ protected function setUp(): void {
7073 $ this ->subAdminManager ,
7174 $ this ->l10nFactory ,
7275 $ this ->rootFolder ,
73- $ this ->logger
76+ $ this ->logger ,
77+ $ this ->groupDisplayNameCache ,
7478 ])
7579 ->onlyMethods (['fillStorageInfo ' ])
7680 ->getMock ();
@@ -490,7 +494,18 @@ public function testGetGroupUsersDetails(): void {
490494 ->method ('getSubAdminsGroups ' )
491495 ->willReturn ([]);
492496
493- $ this ->api ->getGroupUsersDetails ($ gid );
497+ $ this ->groupDisplayNameCache
498+ ->method ('getDisplayName ' )
499+ ->with ('ncg1 ' )
500+ ->willReturn ('Group One ' );
501+
502+ $ result = $ this ->api ->getGroupUsersDetails ($ gid );
503+
504+ $ data = $ result ->getData ();
505+ $ this ->assertSame (['ncu1 ' ], array_keys ($ data ['users ' ]));
506+ $ this ->assertEquals ([
507+ ['id ' => 'ncg1 ' , 'displayname ' => 'Group One ' ],
508+ ], $ data ['groups ' ]);
494509 }
495510
496511 public function testGetGroupUsersDetailsEncoded (): void {
@@ -534,6 +549,17 @@ public function testGetGroupUsersDetailsEncoded(): void {
534549 ->method ('getSubAdminsGroups ' )
535550 ->willReturn ([]);
536551
537- $ this ->api ->getGroupUsersDetails (urlencode ($ gid ));
552+ $ this ->groupDisplayNameCache
553+ ->method ('getDisplayName ' )
554+ ->with ('Department A/B C/D ' )
555+ ->willReturn ('Department A/B C/D-name ' );
556+
557+ $ result = $ this ->api ->getGroupUsersDetails (urlencode ($ gid ));
558+
559+ $ data = $ result ->getData ();
560+ $ this ->assertSame (['ncu1 ' ], array_keys ($ data ['users ' ]));
561+ $ this ->assertEquals ([
562+ ['id ' => 'Department A/B C/D ' , 'displayname ' => 'Department A/B C/D-name ' ],
563+ ], $ data ['groups ' ]);
538564 }
539565}
0 commit comments