@@ -118,6 +118,10 @@ public function testTearDown(): void {
118118 $ this ->setupManager ->tearDown ();
119119 }
120120
121+ /**
122+ * Tests that a path is not set up twice for providers implementing
123+ * IPartialMountProvider in setupForPath.
124+ */
121125 public function testSetupForPathWithPartialProviderSkipsAlreadySetupPath (): void {
122126 $ cachedMount = $ this ->getCachedMountInfo ($ this ->mountPoint , 42 );
123127
@@ -140,6 +144,7 @@ public function testSetupForPathWithPartialProviderSkipsAlreadySetupPath(): void
140144 ->with (
141145 SetupManagerTestPartialMountProvider::class,
142146 $ this ->path ,
147+ false ,
143148 $ this ->callback (function (array $ args ) use ($ cachedMount ) {
144149 $ this ->assertCount (1 , $ args );
145150 $ this ->assertInstanceOf (IMountProviderArgs::class, $ args [0 ]);
@@ -172,6 +177,10 @@ public function testSetupForPathWithPartialProviderSkipsAlreadySetupPath(): void
172177 $ this ->setupManager ->setupForPath ($ this ->path , false );
173178 }
174179
180+ /**
181+ * Tests that providers that are not implementing IPartialMountProvider are
182+ * not set up more than once by setupForPath.
183+ */
175184 public function testSetupForPathWithNonPartialProviderSkipsAlreadySetupProvider (): void {
176185 $ cachedMount = $ this ->getCachedMountInfo ($ this ->mountPoint , 42 ,
177186 IMountProvider::class);
@@ -211,6 +220,11 @@ public function testSetupForPathWithNonPartialProviderSkipsAlreadySetupProvider(
211220 $ this ->setupManager ->setupForPath ($ this ->path , false );
212221 }
213222
223+ /**
224+ * Tests that setupForPath does not instantiate already set up providers
225+ * when called for the same path first with $withChildren set to true
226+ * and then set to false.
227+ */
214228 public function testSetupForPathWithChildrenAndNonPartialProviderSkipsAlreadySetupProvider (): void {
215229 $ cachedMount = $ this ->getCachedMountInfo ($ this ->mountPoint , 42 , IMountProvider::class);
216230 $ additionalCachedMount = $ this ->getCachedMountInfo ($ this ->mountPoint . 'additional/ ' , 43 , SetupManagerTestFullMountProvider::class);
@@ -269,6 +283,10 @@ public function testSetupForPathWithChildrenAndNonPartialProviderSkipsAlreadySet
269283 $ this ->setupManager ->setupForPath ($ this ->path , false );
270284 }
271285
286+ /**
287+ * Tests that setupForPath does not set up child mounts again if a parent
288+ * was set up with $withChildren set to true.
289+ */
272290 public function testSetupForPathWithChildrenAndPartialProviderSkipsIfParentAlreadySetup (): void {
273291 $ childPath = "{$ this ->path }/child " ;
274292 $ childMountPoint = "{$ childPath }/ " ;
@@ -322,6 +340,7 @@ public function testSetupForPathWithChildrenAndPartialProviderSkipsIfParentAlrea
322340 ->willReturnCallback (function (
323341 string $ providerClass ,
324342 string $ pathArg ,
343+ bool $ forChildren ,
325344 array $ mountProviderArgs ,
326345 ) use (
327346 $ cachedChildMount ,
@@ -335,14 +354,17 @@ public function testSetupForPathWithChildrenAndPartialProviderSkipsIfParentAlrea
335354 // call for the parent
336355 $ expectedCachedMount = $ cachedMount ;
337356 $ mountPoints = [$ partialMount ];
357+ $ expectedForChildren = false ;
338358 } else {
339359 // call for the children
340360 $ expectedCachedMount = $ cachedChildMount ;
341361 $ mountPoints = [$ partialChildMount ];
362+ $ expectedForChildren = true ;
342363 }
343364
344365 $ this ->assertSame (SetupManagerTestPartialMountProvider::class, $ providerClass );
345366 $ this ->assertSame ($ expectedPath , $ pathArg );
367+ $ this ->assertSame ($ expectedForChildren , $ forChildren );
346368 $ this ->assertCount (1 , $ mountProviderArgs );
347369 $ this ->assertInstanceOf (IMountProviderArgs::class, $ mountProviderArgs [0 ]);
348370 $ this ->assertSame ($ expectedCachedMount , $ mountProviderArgs [0 ]->mountInfo );
@@ -376,6 +398,10 @@ public function testSetupForPathWithChildrenAndPartialProviderSkipsIfParentAlrea
376398 $ this ->setupManager ->setupForPath ($ childPath , true );
377399 }
378400
401+ /**
402+ * Tests that when called twice setupForPath does not set up mounts from
403+ * providers implementing IPartialMountProviders or IMountProvider.
404+ */
379405 public function testSetupForPathHandlesPartialAndFullProvidersWithChildren (): void {
380406 $ parentPartialCachedMount = $ this ->getCachedMountInfo ($ this ->mountPoint , 42 );
381407 $ childCachedPartialMount = $ this ->getCachedMountInfo ("{$ this ->mountPoint }partial/ " , 43 );
@@ -419,7 +445,7 @@ public function testSetupForPathHandlesPartialAndFullProvidersWithChildren(): vo
419445 $ invokedCount = $ this ->exactly (2 );
420446 $ this ->mountProviderCollection ->expects ($ invokedCount )
421447 ->method ('getUserMountsFromProviderByPath ' )
422- ->willReturnCallback (function (string $ providerClass , string $ pathArg , array $ mountProviderArgs ) use (
448+ ->willReturnCallback (function (string $ providerClass , string $ pathArg , bool $ forChildren , array $ mountProviderArgs ) use (
423449 $ childCachedPartialMount ,
424450 $ childPartialMount ,
425451 $ parentPartialMount ,
@@ -430,14 +456,17 @@ public function testSetupForPathHandlesPartialAndFullProvidersWithChildren(): vo
430456 // call for the parent
431457 $ expectedCachedMount = $ parentPartialCachedMount ;
432458 $ mountPoints = [$ parentPartialMount ];
459+ $ expectedForChildren = false ;
433460 } else {
434461 // call for the children
435462 $ expectedCachedMount = $ childCachedPartialMount ;
436463 $ mountPoints = [$ childPartialMount ];
464+ $ expectedForChildren = true ;
437465 }
438466
439467 $ this ->assertSame (SetupManagerTestPartialMountProvider::class, $ providerClass );
440468 $ this ->assertSame ($ expectedPath , $ pathArg );
469+ $ this ->assertSame ($ expectedForChildren , $ forChildren );
441470 $ this ->assertCount (1 , $ mountProviderArgs );
442471 $ this ->assertInstanceOf (IMountProviderArgs::class, $ mountProviderArgs [0 ]);
443472 $ this ->assertSame ($ expectedCachedMount , $ mountProviderArgs [0 ]->mountInfo );
@@ -488,7 +517,7 @@ public function getMountsForUser(IUser $user, IStorageFactory $loader): array {
488517 return [];
489518 }
490519
491- public function getMountsForPath (string $ path , array $ mountProviderArgs , IStorageFactory $ loader ): array {
520+ public function getMountsForPath (string $ path , bool $ forChildren , array $ mountProviderArgs , IStorageFactory $ loader ): array {
492521 return [];
493522 }
494523}
0 commit comments