@@ -47,6 +47,7 @@ public function setUp() {
4747 $ userBackend = new Dummy ();
4848 $ userBackend ->createUser ('u1 ' , '' );
4949 $ userBackend ->createUser ('u2 ' , '' );
50+ $ userBackend ->createUser ('u3 ' , '' );
5051 $ this ->userManager ->registerBackend ($ userBackend );
5152 $ this ->cache = new \OC \Files \Config \UserMountCache ($ this ->connection , $ this ->userManager , $ this ->createMock (Log::class));
5253 }
@@ -211,6 +212,7 @@ public function testChangeMountId() {
211212 public function testGetMountsForUser () {
212213 $ user1 = $ this ->userManager ->get ('u1 ' );
213214 $ user2 = $ this ->userManager ->get ('u2 ' );
215+ $ user3 = $ this ->userManager ->get ('u3 ' );
214216
215217 list ($ storage1 , $ id1 ) = $ this ->getStorage (1 );
216218 list ($ storage2 , $ id2 ) = $ this ->getStorage (2 );
@@ -219,9 +221,12 @@ public function testGetMountsForUser() {
219221
220222 $ this ->cache ->registerMounts ($ user1 , [$ mount1 , $ mount2 ]);
221223 $ this ->cache ->registerMounts ($ user2 , [$ mount2 ]);
224+ $ this ->cache ->registerMounts ($ user3 , [$ mount2 ]);
222225
223226 $ this ->clearCache ();
224227
228+ $ user3 ->delete ();
229+
225230 $ cachedMounts = $ this ->cache ->getMountsForUser ($ user1 );
226231
227232 $ this ->assertCount (2 , $ cachedMounts );
@@ -234,6 +239,9 @@ public function testGetMountsForUser() {
234239 $ this ->assertEquals ($ user1 , $ cachedMounts [1 ]->getUser ());
235240 $ this ->assertEquals ($ id2 , $ cachedMounts [1 ]->getRootId ());
236241 $ this ->assertEquals (2 , $ cachedMounts [1 ]->getStorageId ());
242+
243+ $ cachedMounts = $ this ->cache ->getMountsForUser ($ user3 );
244+ $ this ->assertEmpty ($ cachedMounts );
237245 }
238246
239247 public function testGetMountsByStorageId () {
@@ -431,4 +439,20 @@ public function testGetMountsForFileIdSubFolderMountOutside() {
431439
432440 $ this ->assertCount (0 , $ cachedMounts );
433441 }
442+
443+
444+ public function testGetMountsForFileIdDeletedUser () {
445+ $ user1 = $ this ->userManager ->get ('u1 ' );
446+
447+ list ($ storage1 , $ rootId ) = $ this ->getStorage (2 );
448+ $ rootId = $ this ->createCacheEntry ('' , 2 );
449+ $ mount1 = new MountPoint ($ storage1 , '/foo/ ' );
450+ $ this ->cache ->registerMounts ($ user1 , [$ mount1 ]);
451+
452+ $ user1 ->delete ();
453+ $ this ->clearCache ();
454+
455+ $ cachedMounts = $ this ->cache ->getMountsForFileId ($ rootId );
456+ $ this ->assertEmpty ($ cachedMounts );
457+ }
434458}
0 commit comments