@@ -39,11 +39,11 @@ class MountProviderTest extends \Test\TestCase {
3939 protected function setUp (): void {
4040 parent ::setUp ();
4141
42- $ this ->config = $ this ->getMockBuilder (IConfig::class)-> getMock ( );
43- $ this ->user = $ this ->getMockBuilder (IUser::class)-> getMock ( );
44- $ this ->loader = $ this ->getMockBuilder ( ' OCP\Files\Storage\ IStorageFactory' )-> getMock ( );
45- $ this ->shareManager = $ this ->getMockBuilder (IManager::class)-> getMock ( );
46- $ this ->logger = $ this ->getMockBuilder (LoggerInterface::class)-> getMock ( );
42+ $ this ->config = $ this ->createMock (IConfig::class);
43+ $ this ->user = $ this ->createMock (IUser::class);
44+ $ this ->loader = $ this ->createMock ( IStorageFactory::class );
45+ $ this ->shareManager = $ this ->createMock (IManager::class);
46+ $ this ->logger = $ this ->createMock (LoggerInterface::class);
4747 $ eventDispatcher = $ this ->createMock (IEventDispatcher::class);
4848 $ cacheFactory = $ this ->createMock (ICacheFactory::class);
4949 $ cacheFactory ->method ('createLocal ' )
@@ -53,11 +53,7 @@ protected function setUp(): void {
5353 $ this ->provider = new MountProvider ($ this ->config , $ this ->shareManager , $ this ->logger , $ eventDispatcher , $ cacheFactory , $ mountManager );
5454 }
5555
56- private function makeMockShareAttributes ($ attrs ) {
57- if ($ attrs === null ) {
58- return null ;
59- }
60-
56+ private function makeMockShareAttributes (array $ attrs ): IShareAttributes &MockObject {
6157 $ shareAttributes = $ this ->createMock (IShareAttributes::class);
6258 $ shareAttributes ->method ('toArray ' )->willReturn ($ attrs );
6359 $ shareAttributes ->method ('getAttribute ' )->willReturnCallback (
@@ -74,14 +70,14 @@ function ($scope, $key) use ($attrs) {
7470 return $ shareAttributes ;
7571 }
7672
77- private function makeMockShare ($ id , $ nodeId , $ owner = 'user2 ' , $ target = null , $ permissions = 31 , $ attributes = null ) {
73+ private function makeMockShare (string $ id , $ nodeId , $ owner = 'user2 ' , $ target = null , $ permissions = 31 , $ attributes = null ) {
7874 $ share = $ this ->createMock (IShare::class);
7975 $ share ->expects ($ this ->any ())
8076 ->method ('getPermissions ' )
8177 ->willReturn ($ permissions );
8278 $ share ->expects ($ this ->any ())
8379 ->method ('getAttributes ' )
84- ->willReturn ($ this ->makeMockShareAttributes ($ attributes ));
80+ ->willReturn ($ attributes === null ? null : $ this ->makeMockShareAttributes ($ attributes ));
8581 $ share ->expects ($ this ->any ())
8682 ->method ('getShareOwner ' )
8783 ->willReturn ($ owner );
@@ -114,25 +110,25 @@ public function testExcludeShares(): void {
114110 $ attr1 = [];
115111 $ attr2 = [['scope ' => 'permission ' , 'key ' => 'download ' , 'value ' => true ]];
116112 $ userShares = [
117- $ this ->makeMockShare (1 , 100 , 'user2 ' , '/share2 ' , 0 , $ attr1 ),
118- $ this ->makeMockShare (2 , 100 , 'user2 ' , '/share2 ' , 31 , $ attr2 ),
113+ $ this ->makeMockShare (' 1 ' , 100 , 'user2 ' , '/share2 ' , 0 , $ attr1 ),
114+ $ this ->makeMockShare (' 2 ' , 100 , 'user2 ' , '/share2 ' , 31 , $ attr2 ),
119115 ];
120116 $ groupShares = [
121- $ this ->makeMockShare (3 , 100 , 'user2 ' , '/share2 ' , 0 , $ attr1 ),
122- $ this ->makeMockShare (4 , 101 , 'user2 ' , '/share4 ' , 31 , $ attr2 ),
123- $ this ->makeMockShare (5 , 100 , 'user1 ' , '/share4 ' , 31 , $ attr2 ),
117+ $ this ->makeMockShare (' 3 ' , 100 , 'user2 ' , '/share2 ' , 0 , $ attr1 ),
118+ $ this ->makeMockShare (' 4 ' , 101 , 'user2 ' , '/share4 ' , 31 , $ attr2 ),
119+ $ this ->makeMockShare (' 5 ' , 100 , 'user1 ' , '/share4 ' , 31 , $ attr2 ),
124120 ];
125121 $ roomShares = [
126- $ this ->makeMockShare (6 , 102 , 'user2 ' , '/share6 ' , 0 ),
127- $ this ->makeMockShare (7 , 102 , 'user1 ' , '/share6 ' , 31 ),
128- $ this ->makeMockShare (8 , 102 , 'user2 ' , '/share6 ' , 31 ),
129- $ this ->makeMockShare (9 , 102 , 'user2 ' , '/share6 ' , 31 ),
122+ $ this ->makeMockShare (' 6 ' , 102 , 'user2 ' , '/share6 ' , 0 ),
123+ $ this ->makeMockShare (' 7 ' , 102 , 'user1 ' , '/share6 ' , 31 ),
124+ $ this ->makeMockShare (' 8 ' , 102 , 'user2 ' , '/share6 ' , 31 ),
125+ $ this ->makeMockShare (' 9 ' , 102 , 'user2 ' , '/share6 ' , 31 ),
130126 ];
131127 $ deckShares = [
132- $ this ->makeMockShare (10 , 103 , 'user2 ' , '/share7 ' , 0 ),
133- $ this ->makeMockShare (11 , 103 , 'user1 ' , '/share7 ' , 31 ),
134- $ this ->makeMockShare (12 , 103 , 'user2 ' , '/share7 ' , 31 ),
135- $ this ->makeMockShare (13 , 103 , 'user2 ' , '/share7 ' , 31 ),
128+ $ this ->makeMockShare (' 10 ' , 103 , 'user2 ' , '/share7 ' , 0 ),
129+ $ this ->makeMockShare (' 11 ' , 103 , 'user1 ' , '/share7 ' , 31 ),
130+ $ this ->makeMockShare (' 12 ' , 103 , 'user2 ' , '/share7 ' , 31 ),
131+ $ this ->makeMockShare (' 13 ' , 103 , 'user2 ' , '/share7 ' , 31 ),
136132 ];
137133 // tests regarding circles and sciencemesh are made in the apps themselves.
138134 $ circleShares = [];
@@ -198,10 +194,10 @@ public static function mergeSharesDataProvider(): array {
198194 // #0: share as outsider with "group1" and "user1" with same permissions
199195 [
200196 [
201- [1 , 100 , 'user2 ' , '/share2 ' , 31 , null ],
197+ [' 1 ' , 100 , 'user2 ' , '/share2 ' , 31 , null ],
202198 ],
203199 [
204- [2 , 100 , 'user2 ' , '/share2 ' , 31 , null ],
200+ [' 2 ' , 100 , 'user2 ' , '/share2 ' , 31 , null ],
205201 ],
206202 [
207203 // combined, user share has higher priority
@@ -211,10 +207,10 @@ public static function mergeSharesDataProvider(): array {
211207 // #1: share as outsider with "group1" and "user1" with different permissions
212208 [
213209 [
214- [1 , 100 , 'user2 ' , '/share ' , 31 , [['scope ' => 'permission ' , 'key ' => 'download ' , 'value ' => true ], ['scope ' => 'app ' , 'key ' => 'attribute1 ' , 'value ' => true ]]],
210+ [' 1 ' , 100 , 'user2 ' , '/share ' , 31 , [['scope ' => 'permission ' , 'key ' => 'download ' , 'value ' => true ], ['scope ' => 'app ' , 'key ' => 'attribute1 ' , 'value ' => true ]]],
215211 ],
216212 [
217- [2 , 100 , 'user2 ' , '/share ' , 15 , [['scope ' => 'permission ' , 'key ' => 'download ' , 'value ' => false ], ['scope ' => 'app ' , 'key ' => 'attribute2 ' , 'value ' => false ]]],
213+ [' 2 ' , 100 , 'user2 ' , '/share ' , 15 , [['scope ' => 'permission ' , 'key ' => 'download ' , 'value ' => false ], ['scope ' => 'app ' , 'key ' => 'attribute2 ' , 'value ' => false ]]],
218214 ],
219215 [
220216 // use highest permissions
@@ -226,8 +222,8 @@ public static function mergeSharesDataProvider(): array {
226222 [
227223 ],
228224 [
229- [1 , 100 , 'user2 ' , '/share ' , 31 , null ],
230- [2 , 100 , 'user2 ' , '/share ' , 31 , []],
225+ [' 1 ' , 100 , 'user2 ' , '/share ' , 31 , null ],
226+ [' 2 ' , 100 , 'user2 ' , '/share ' , 31 , []],
231227 ],
232228 [
233229 // combined, first group share has higher priority
@@ -239,8 +235,8 @@ public static function mergeSharesDataProvider(): array {
239235 [
240236 ],
241237 [
242- [1 , 100 , 'user2 ' , '/share ' , 31 , [['scope ' => 'permission ' , 'key ' => 'download ' , 'value ' => false ]]],
243- [2 , 100 , 'user2 ' , '/share ' , 15 , [['scope ' => 'permission ' , 'key ' => 'download ' , 'value ' => true ]]],
238+ [' 1 ' , 100 , 'user2 ' , '/share ' , 31 , [['scope ' => 'permission ' , 'key ' => 'download ' , 'value ' => false ]]],
239+ [' 2 ' , 100 , 'user2 ' , '/share ' , 15 , [['scope ' => 'permission ' , 'key ' => 'download ' , 'value ' => true ]]],
244240 ],
245241 [
246242 // use higher permissions (most permissive)
@@ -252,7 +248,7 @@ public static function mergeSharesDataProvider(): array {
252248 [
253249 ],
254250 [
255- [1 , 100 , 'user1 ' , '/share ' , 31 , []],
251+ [' 1 ' , 100 , 'user1 ' , '/share ' , 31 , []],
256252 ],
257253 [
258254 // no received share since "user1" is the sharer/owner
@@ -263,8 +259,8 @@ public static function mergeSharesDataProvider(): array {
263259 [
264260 ],
265261 [
266- [1 , 100 , 'user1 ' , '/share ' , 31 , [['scope ' => 'permission ' , 'key ' => 'download ' , 'value ' => true ]]],
267- [2 , 100 , 'user1 ' , '/share ' , 15 , [['scope ' => 'permission ' , 'key ' => 'download ' , 'value ' => false ]]],
262+ [' 1 ' , 100 , 'user1 ' , '/share ' , 31 , [['scope ' => 'permission ' , 'key ' => 'download ' , 'value ' => true ]]],
263+ [' 2 ' , 100 , 'user1 ' , '/share ' , 15 , [['scope ' => 'permission ' , 'key ' => 'download ' , 'value ' => false ]]],
268264 ],
269265 [
270266 // no received share since "user1" is the sharer/owner
@@ -275,7 +271,7 @@ public static function mergeSharesDataProvider(): array {
275271 [
276272 ],
277273 [
278- [1 , 100 , 'user2 ' , '/share ' , 0 , []],
274+ [' 1 ' , 100 , 'user2 ' , '/share ' , 0 , []],
279275 ],
280276 [
281277 // no received share since "user1" opted out
@@ -284,10 +280,10 @@ public static function mergeSharesDataProvider(): array {
284280 // #7: share as outsider with "group1" and "user1" where recipient renamed in between
285281 [
286282 [
287- [1 , 100 , 'user2 ' , '/share2-renamed ' , 31 , []],
283+ [' 1 ' , 100 , 'user2 ' , '/share2-renamed ' , 31 , []],
288284 ],
289285 [
290- [2 , 100 , 'user2 ' , '/share2 ' , 31 , []],
286+ [' 2 ' , 100 , 'user2 ' , '/share2 ' , 31 , []],
291287 ],
292288 [
293289 // use target of least recent share
@@ -297,10 +293,10 @@ public static function mergeSharesDataProvider(): array {
297293 // #8: share as outsider with "group1" and "user1" where recipient renamed in between
298294 [
299295 [
300- [2 , 100 , 'user2 ' , '/share2 ' , 31 , []],
296+ [' 2 ' , 100 , 'user2 ' , '/share2 ' , 31 , []],
301297 ],
302298 [
303- [1 , 100 , 'user2 ' , '/share2-renamed ' , 31 , []],
299+ [' 1 ' , 100 , 'user2 ' , '/share2-renamed ' , 31 , []],
304300 ],
305301 [
306302 // use target of least recent share
@@ -310,10 +306,10 @@ public static function mergeSharesDataProvider(): array {
310306 // #9: share as outsider with "nullgroup" and "user1" where recipient renamed in between
311307 [
312308 [
313- [2 , 100 , 'user2 ' , '/share2 ' , 31 , []],
309+ [' 2 ' , 100 , 'user2 ' , '/share2 ' , 31 , []],
314310 ],
315311 [
316- [1 , 100 , 'nullgroup ' , '/share2-renamed ' , 31 , []],
312+ [' 1 ' , 100 , 'nullgroup ' , '/share2-renamed ' , 31 , []],
317313 ],
318314 [
319315 // use target of least recent share
@@ -355,7 +351,6 @@ public function testMergeShares(array $userShares, array $groupShares, array $ex
355351 $ circleShares = [];
356352 $ roomShares = [];
357353 $ deckShares = [];
358- $ scienceMeshShares = [];
359354 $ this ->shareManager ->expects ($ this ->exactly (5 ))
360355 ->method ('getSharedWith ' )
361356 ->willReturnMap ([
@@ -384,7 +379,7 @@ public function testMergeShares(array $userShares, array $groupShares, array $ex
384379
385380 foreach ($ mounts as $ index => $ mount ) {
386381 $ expectedShare = $ expectedShares [$ index ];
387- $ this ->assertInstanceOf (' OCA\Files_Sharing\ SharedMount' , $ mount );
382+ $ this ->assertInstanceOf (SharedMount::class , $ mount );
388383
389384 // supershare
390385 /** @var SharedMount $mount */
0 commit comments