Пример #1
0
 public function testGetMountsForFileIdSubFolderMountOutside()
 {
     $user1 = $this->userManager->get('u1');
     $this->createCacheEntry('', 2);
     $folderId = $this->createCacheEntry('/foo', 2);
     $fileId = $this->createCacheEntry('/bar/asd', 2);
     $mount1 = new MountPoint($this->getStorage(2, $folderId), '/foo/');
     $this->cache->registerMounts($user1, [$mount1]);
     $this->clearCache();
     $cachedMounts = $this->cache->getMountsForFileId($fileId);
     $this->assertCount(0, $cachedMounts);
 }
Пример #2
0
 public function testGetMountsByRootId()
 {
     $user1 = $this->userManager->get('u1');
     $user2 = $this->userManager->get('u2');
     $mount1 = new MountPoint($this->getStorage(1, 2), '/foo/');
     $mount2 = new MountPoint($this->getStorage(3, 4), '/bar/');
     $this->cache->registerMounts($user1, [$mount1, $mount2]);
     $this->cache->registerMounts($user2, [$mount2]);
     $this->clearCache();
     $cachedMounts = $this->cache->getMountsForRootId(4);
     usort($cachedMounts, function (ICachedMountInfo $a, ICachedMountInfo $b) {
         return strcmp($a->getUser()->getUID(), $b->getUser()->getUID());
     });
     $this->assertCount(2, $cachedMounts);
     $this->assertEquals('/bar/', $cachedMounts[0]->getMountPoint());
     $this->assertEquals($user1, $cachedMounts[0]->getUser());
     $this->assertEquals(4, $cachedMounts[0]->getRootId());
     $this->assertEquals(3, $cachedMounts[0]->getStorageId());
     $this->assertEquals('/bar/', $cachedMounts[1]->getMountPoint());
     $this->assertEquals($user2, $cachedMounts[1]->getUser());
     $this->assertEquals(4, $cachedMounts[1]->getRootId());
     $this->assertEquals(3, $cachedMounts[1]->getStorageId());
 }