99
1010use OCA \Files_Sharing \Controller \ShareesAPIController ;
1111use OCA \Files_Sharing \Tests \TestCase ;
12+ use OCP \App \IAppManager ;
1213use OCP \AppFramework \Http \DataResponse ;
1314use OCP \AppFramework \OCS \OCSBadRequestException ;
1415use OCP \Collaboration \Collaborators \ISearch ;
2829 * @package OCA\Files_Sharing\Tests\API
2930 */
3031class ShareesAPIControllerTest extends TestCase {
31- /** @var ShareesAPIController */
32- protected $ sharees ;
33-
34- /** @var string */
35- protected $ uid ;
36-
37- /** @var IRequest|MockObject */
38- protected $ request ;
39-
40- /** @var IManager|MockObject */
32+ protected ShareesAPIController $ sharees ;
33+ protected string $ uid ;
34+ protected IRequest &MockObject $ request ;
4135 protected $ shareManager ;
42-
43- /** @var ISearch|MockObject */
44- protected $ collaboratorSearch ;
45-
46- /** @var IConfig|MockObject */
47- protected $ config ;
36+ protected ISearch &MockObject $ collaboratorSearch ;
37+ protected IConfig &MockObject $ config ;
38+ protected FederatedShareProvider &MockObject $ federatedShareProvider ;
39+ protected IAppManager &MockObject $ appManager ;
4840
4941 protected function setUp (): void {
5042 parent ::setUp ();
@@ -54,10 +46,11 @@ protected function setUp(): void {
5446 $ this ->shareManager = $ this ->createMock (IManager::class);
5547 $ this ->config = $ this ->createMock (IConfig::class);
5648
57- /** @var IURLGenerator|MockObject $urlGeneratorMock */
5849 $ urlGeneratorMock = $ this ->createMock (IURLGenerator::class);
5950
6051 $ this ->collaboratorSearch = $ this ->createMock (ISearch::class);
52+ $ this ->federatedShareProvider = $ this ->createMock (FederatedShareProvider::class);
53+ $ this ->appManager = $ this ->createMock (IAppManager::class);
6154
6255 $ this ->sharees = new ShareesAPIController (
6356 'files_sharing ' ,
@@ -66,7 +59,9 @@ protected function setUp(): void {
6659 $ this ->config ,
6760 $ urlGeneratorMock ,
6861 $ this ->shareManager ,
69- $ this ->collaboratorSearch
62+ $ this ->collaboratorSearch ,
63+ $ this ->federatedShareProvider
64+ $ this ->appManager ,
7065 );
7166 }
7267
@@ -260,7 +255,9 @@ public function testSearch(
260255 $ config ,
261256 $ urlGenerator ,
262257 $ this ->shareManager ,
263- $ this ->collaboratorSearch
258+ $ this ->collaboratorSearch ,
259+ $ this ->federatedShareProvider ,
260+ $ this ->appManager ,
264261 ])
265262 ->onlyMethods (['isRemoteSharingAllowed ' , 'isRemoteGroupSharingAllowed ' ])
266263 ->getMock ();
@@ -269,8 +266,8 @@ public function testSearch(
269266 sort ($ expectedShareTypes );
270267
271268 $ this ->collaboratorSearch ->expects ($ this ->once ())
272- ->method ('search ' )
273- ->with ($ search , $ expectedShareTypes , $ this ->anything (), $ perPage , $ perPage * ($ page - 1 ))
269+ ->method ('filteredSearch ' )
270+ ->with ($ search , $ expectedShareTypes , $ this ->anything (), $ itemType , null , $ perPage , $ perPage * ($ page - 1 ))
274271 ->willReturn ([[], false ]);
275272
276273 $ sharees ->expects ($ this ->any ())
@@ -359,15 +356,17 @@ public function testSearchInvalid($getData, $message): void {
359356 $ config ,
360357 $ urlGenerator ,
361358 $ this ->shareManager ,
362- $ this ->collaboratorSearch
359+ $ this ->collaboratorSearch ,
360+ $ this ->federatedShareProvider ,
361+ $ this ->appManager ,
363362 ])
364363 ->onlyMethods (['isRemoteSharingAllowed ' ])
365364 ->getMock ();
366365 $ sharees ->expects ($ this ->never ())
367366 ->method ('isRemoteSharingAllowed ' );
368367
369368 $ this ->collaboratorSearch ->expects ($ this ->never ())
370- ->method ('search ' );
369+ ->method ('filteredSearch ' );
371370
372371 try {
373372 $ sharees ->search ('' , null , $ page , $ perPage , null );
0 commit comments