*/
protected $mountId;
+ /**
+ * @var string
+ */
+ protected $rootInternalPath;
+
/**
* CachedMountInfo constructor.
*
* @param int $rootId
* @param string $mountPoint
* @param int|null $mountId
+ * @param string $rootInternalPath
*/
- public function __construct(IUser $user, $storageId, $rootId, $mountPoint, $mountId = null) {
+ public function __construct(IUser $user, $storageId, $rootId, $mountPoint, $mountId = null, $rootInternalPath = '') {
$this->user = $user;
$this->storageId = $storageId;
$this->rootId = $rootId;
$this->mountPoint = $mountPoint;
$this->mountId = $mountId;
+ $this->rootInternalPath = $rootInternalPath;
}
/**
public function getMountId() {
return $this->mountId;
}
+
+ /**
+ * Get the internal path (within the storage) of the root of the mount
+ *
+ * @return string
+ */
+ public function getRootInternalPath() {
+ return $this->rootInternalPath;
+ }
}
public function getMountId() {
return $this->mount->getMountId();
}
+
+ /**
+ * Get the internal path (within the storage) of the root of the mount
+ *
+ * @return string
+ */
+ public function getRootInternalPath() {
+ return $this->mount->getInternalPath($this->mount->getMountPoint());
+ }
}
use OCP\Files\Config\ICachedMountInfo;
use OCP\Files\Config\IUserMountCache;
use OCP\Files\Mount\IMountPoint;
+use OCP\Files\Node;
use OCP\Files\NotFoundException;
use OCP\ICache;
use OCP\IDBConnection;
private function dbRowToMountInfo(array $row) {
$user = $this->userManager->get($row['user_id']);
- return new CachedMountInfo($user, (int)$row['storage_id'], (int)$row['root_id'], $row['mount_point'], $row['mount_id']);
+ return new CachedMountInfo($user, (int)$row['storage_id'], (int)$row['root_id'], $row['mount_point'], $row['mount_id'], isset($row['path'])? $row['path']:'');
}
/**
public function getMountsForUser(IUser $user) {
if (!isset($this->mountsForUsers[$user->getUID()])) {
$builder = $this->connection->getQueryBuilder();
- $query = $builder->select('storage_id', 'root_id', 'user_id', 'mount_point', 'mount_id')
- ->from('mounts')
+ $query = $builder->select('storage_id', 'root_id', 'user_id', 'mount_point', 'mount_id', 'f.path')
+ ->from('mounts', 'm')
+ ->innerJoin('m', 'filecache', 'f', $builder->expr()->eq('m.root_id', 'f.fileid'))
->where($builder->expr()->eq('user_id', $builder->createPositionalParameter($user->getUID())));
$rows = $query->execute()->fetchAll();
*/
public function getMountsForStorageId($numericStorageId) {
$builder = $this->connection->getQueryBuilder();
- $query = $builder->select('storage_id', 'root_id', 'user_id', 'mount_point', 'mount_id')
- ->from('mounts')
+ $query = $builder->select('storage_id', 'root_id', 'user_id', 'mount_point', 'mount_id', 'f.path')
+ ->from('mounts', 'm')
+ ->innerJoin('m', 'filecache', 'f' , $builder->expr()->eq('m.root_id', 'f.fileid'))
->where($builder->expr()->eq('storage_id', $builder->createPositionalParameter($numericStorageId, IQueryBuilder::PARAM_INT)));
$rows = $query->execute()->fetchAll();
*/
public function getMountsForRootId($rootFileId) {
$builder = $this->connection->getQueryBuilder();
- $query = $builder->select('storage_id', 'root_id', 'user_id', 'mount_point', 'mount_id')
- ->from('mounts')
+ $query = $builder->select('storage_id', 'root_id', 'user_id', 'mount_point', 'mount_id', 'f.path')
+ ->from('mounts', 'm')
+ ->innerJoin('m', 'filecache', 'f', $builder->expr()->eq('m.root_id', 'f.fileid'))
->where($builder->expr()->eq('root_id', $builder->createPositionalParameter($rootFileId, IQueryBuilder::PARAM_INT)));
$rows = $query->execute()->fetchAll();
private function getCacheInfoFromFileId($fileId) {
if (!isset($this->cacheInfoCache[$fileId])) {
$builder = $this->connection->getQueryBuilder();
- $query = $builder->select('storage', 'path')
+ $query = $builder->select('storage', 'path', 'mimetype')
->from('filecache')
->where($builder->expr()->eq('fileid', $builder->createNamedParameter($fileId, IQueryBuilder::PARAM_INT)));
if (is_array($row)) {
$this->cacheInfoCache[$fileId] = [
(int)$row['storage'],
- $row['path']
+ $row['path'],
+ (int)$row['mimetype']
];
} else {
throw new NotFoundException('File with id "' . $fileId . '" not found');
if ($fileId === $mount->getRootId()) {
return true;
}
- try {
- list(, $internalMountPath) = $this->getCacheInfoFromFileId($mount->getRootId());
- } catch (NotFoundException $e) {
- return false;
- }
+ $internalMountPath = $mount->getRootInternalPath();
return $internalMountPath === '' || substr($internalPath, 0, strlen($internalMountPath) + 1) === $internalMountPath . '/';
});
-
}
/**
use OC\DB\QueryBuilder\Literal;
use OCP\DB\QueryBuilder\IQueryBuilder;
+use OCP\Files\Config\ICachedMountInfo;
use OCP\Files\FileInfo;
use OCP\Files\Mount\IMountPoint;
use OCP\Files\NotFoundException;
public function getDirectoryListing() {
$folderContent = $this->view->getDirectoryContent($this->path);
- return array_map(function(FileInfo $info) {
+ return array_map(function (FileInfo $info) {
if ($info->getMimetype() === 'httpd/unix-directory') {
return new Folder($this->root, $this->view, $info->getPath(), $info);
} else {
}
}
- return array_map(function(FileInfo $file) {
+ return array_map(function (FileInfo $file) {
return $this->createNode($file->getPath(), $file);
}, $files);
}
* @return \OC\Files\Node\Node[]
*/
public function getById($id) {
+ $mountCache = $this->root->getUserMountCache();
+ $mountsContainingFile = $mountCache->getMountsForFileId($id);
$mounts = $this->root->getMountsIn($this->path);
$mounts[] = $this->root->getMount($this->path);
- // reverse the array so we start with the storage this view is in
- // which is the most likely to contain the file we're looking for
- $mounts = array_reverse($mounts);
+ /** @var IMountPoint[] $folderMounts */
+ $folderMounts = array_combine(array_map(function (IMountPoint $mountPoint) {
+ return $mountPoint->getMountPoint();
+ }, $mounts), $mounts);
+
+ /** @var ICachedMountInfo[] $mountsContainingFile */
+ $mountsContainingFile = array_values(array_filter($mountsContainingFile, function (ICachedMountInfo $cachedMountInfo) use ($folderMounts) {
+ return isset($folderMounts[$cachedMountInfo->getMountPoint()]);
+ }));
- $nodes = array();
- foreach ($mounts as $mount) {
- /**
- * @var \OC\Files\Mount\MountPoint $mount
- */
- if ($mount->getStorage()) {
- $cache = $mount->getStorage()->getCache();
- $internalPath = $cache->getPathById($id);
- if (is_string($internalPath)) {
- $fullPath = $mount->getMountPoint() . $internalPath;
- if (!is_null($path = $this->getRelativePath($fullPath))) {
- $nodes[] = $this->get($path);
- }
- }
- }
+ if (count($mountsContainingFile) === 0) {
+ return [];
}
- return $nodes;
+
+ // we only need to get the cache info once, since all mounts we found point to the same storage
+
+ $mount = $folderMounts[$mountsContainingFile[0]->getMountPoint()];
+ $cacheEntry = $mount->getStorage()->getCache()->get($id);
+ // cache jails will hide the "true" internal path
+ $internalPath = ltrim($mountsContainingFile[0]->getRootInternalPath() . '/' . $cacheEntry->getPath(), '/');
+
+ $nodes = array_map(function (ICachedMountInfo $cachedMountInfo) use ($cacheEntry, $folderMounts, $internalPath) {
+ $mount = $folderMounts[$cachedMountInfo->getMountPoint()];
+ $pathRelativeToMount = substr($internalPath, strlen($cachedMountInfo->getRootInternalPath()));
+ $pathRelativeToMount = ltrim($pathRelativeToMount, '/');
+ $absolutePath = $cachedMountInfo->getMountPoint() . $pathRelativeToMount;
+ return $this->root->createNode($absolutePath, new \OC\Files\FileInfo(
+ $absolutePath, $mount->getStorage(), $cacheEntry->getPath(), $cacheEntry, $mount,
+ \OC::$server->getUserManager()->get($mount->getStorage()->getOwner($pathRelativeToMount))
+ ));
+ }, $mountsContainingFile);
+
+ return array_filter($nodes, function (Node $node) {
+ return $this->getRelativePath($node->getPath());
+ });
}
public function getFreeSpace() {
use OC\Cache\CappedMemoryCache;
use OC\Files\Mount\Manager;
use OC\Files\Mount\MountPoint;
+use OCP\Files\Config\IUserMountCache;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
use OC\Hooks\PublicEmitter;
private $userFolderCache;
+ /**
+ * @var IUserMountCache
+ */
+ private $userMountCache;
+
/**
* @param \OC\Files\Mount\Manager $manager
* @param \OC\Files\View $view
* @param \OC\User\User|null $user
+ * @param IUserMountCache $userMountCache
*/
- public function __construct($manager, $view, $user) {
+ public function __construct($manager, $view, $user, IUserMountCache $userMountCache) {
parent::__construct($this, $view, '');
$this->mountManager = $manager;
$this->user = $user;
$this->emitter = new PublicEmitter();
$this->userFolderCache = new CappedMemoryCache();
+ $this->userMountCache = $userMountCache;
}
/**
public function clearCache() {
$this->userFolderCache = new CappedMemoryCache();
}
+
+ public function getUserMountCache() {
+ return $this->userMountCache;
+ }
}
$this->registerService('SystemTagObjectMapper', function (Server $c) {
return $c->query('SystemTagManagerFactory')->getObjectMapper();
});
- $this->registerService('RootFolder', function () {
+ $this->registerService('RootFolder', function (Server $c) {
$manager = \OC\Files\Filesystem::getMountManager(null);
$view = new View();
- $root = new Root($manager, $view, null);
+ $root = new Root($manager, $view, null, $c->getUserMountCache());
$connector = new HookConnector($root, $view);
$connector->viewToNode();
return $root;
* @since 9.1.0
*/
public function getMountId();
+
+ /**
+ * Get the internal path (within the storage) of the root of the mount
+ *
+ * @return string
+ * @since 9.2.0
+ */
+ public function getRootInternalPath();
}
}
}
- private function getStorage($storageId, $rootId) {
+ private function getStorage($storageId) {
+ $rootId = $this->createCacheEntry('', $storageId);
+
$storageCache = $this->getMockBuilder('\OC\Files\Cache\Storage')
->disableOriginalConstructor()
->getMock();
->method('getCache')
->will($this->returnValue($cache));
- return $storage;
+ return [$storage, $rootId];
}
private function clearCache() {
public function testNewMounts() {
$user = $this->userManager->get('u1');
- $storage = $this->getStorage(10, 20);
+ list($storage) = $this->getStorage(10);
$mount = new MountPoint($storage, '/asd/');
$this->cache->registerMounts($user, [$mount]);
public function testSameMounts() {
$user = $this->userManager->get('u1');
- $storage = $this->getStorage(10, 20);
+ list($storage) = $this->getStorage(10);
$mount = new MountPoint($storage, '/asd/');
$this->cache->registerMounts($user, [$mount]);
public function testRemoveMounts() {
$user = $this->userManager->get('u1');
- $storage = $this->getStorage(10, 20);
+ list($storage) = $this->getStorage(10);
$mount = new MountPoint($storage, '/asd/');
$this->cache->registerMounts($user, [$mount]);
public function testChangeMounts() {
$user = $this->userManager->get('u1');
- $storage = $this->getStorage(10, 20);
+ list($storage) = $this->getStorage(10);
$mount = new MountPoint($storage, '/bar/');
$this->cache->registerMounts($user, [$mount]);
public function testChangeMountId() {
$user = $this->userManager->get('u1');
- $storage = $this->getStorage(10, 20);
+ list($storage) = $this->getStorage(10);
$mount = new MountPoint($storage, '/foo/', null, null, null, null);
$this->cache->registerMounts($user, [$mount]);
$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/');
+ list($storage1, $id1) = $this->getStorage(1);
+ list($storage2, $id2) = $this->getStorage(2);
+ $mount1 = new MountPoint($storage1, '/foo/');
+ $mount2 = new MountPoint($storage2, '/bar/');
$this->cache->registerMounts($user1, [$mount1, $mount2]);
$this->cache->registerMounts($user2, [$mount2]);
$this->assertCount(2, $cachedMounts);
$this->assertEquals('/foo/', $cachedMounts[0]->getMountPoint());
$this->assertEquals($user1, $cachedMounts[0]->getUser());
- $this->assertEquals(2, $cachedMounts[0]->getRootId());
+ $this->assertEquals($id1, $cachedMounts[0]->getRootId());
$this->assertEquals(1, $cachedMounts[0]->getStorageId());
$this->assertEquals('/bar/', $cachedMounts[1]->getMountPoint());
$this->assertEquals($user1, $cachedMounts[1]->getUser());
- $this->assertEquals(4, $cachedMounts[1]->getRootId());
- $this->assertEquals(3, $cachedMounts[1]->getStorageId());
+ $this->assertEquals($id2, $cachedMounts[1]->getRootId());
+ $this->assertEquals(2, $cachedMounts[1]->getStorageId());
}
public function testGetMountsByStorageId() {
$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/');
+ list($storage1, $id1) = $this->getStorage(1);
+ list($storage2, $id2) = $this->getStorage(2);
+ $mount1 = new MountPoint($storage1, '/foo/');
+ $mount2 = new MountPoint($storage2, '/bar/');
$this->cache->registerMounts($user1, [$mount1, $mount2]);
$this->cache->registerMounts($user2, [$mount2]);
$this->clearCache();
- $cachedMounts = $this->cache->getMountsForStorageId(3);
+ $cachedMounts = $this->cache->getMountsForStorageId(2);
$this->sortMounts($cachedMounts);
$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($id2, $cachedMounts[0]->getRootId());
+ $this->assertEquals(2, $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());
+ $this->assertEquals($id2, $cachedMounts[1]->getRootId());
+ $this->assertEquals(2, $cachedMounts[1]->getStorageId());
}
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/');
+ list($storage1, $id1) = $this->getStorage(1);
+ list($storage2, $id2) = $this->getStorage(2);
+ $mount1 = new MountPoint($storage1, '/foo/');
+ $mount2 = new MountPoint($storage2, '/bar/');
$this->cache->registerMounts($user1, [$mount1, $mount2]);
$this->cache->registerMounts($user2, [$mount2]);
$this->clearCache();
- $cachedMounts = $this->cache->getMountsForRootId(4);
+ $cachedMounts = $this->cache->getMountsForRootId($id2);
$this->sortMounts($cachedMounts);
$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($id2, $cachedMounts[0]->getRootId());
+ $this->assertEquals(2, $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());
+ $this->assertEquals($id2, $cachedMounts[1]->getRootId());
+ $this->assertEquals(2, $cachedMounts[1]->getStorageId());
}
private function sortMounts(&$mounts) {
}
private function createCacheEntry($internalPath, $storageId) {
- $this->connection->insertIfNotExist('*PREFIX*filecache', [
+ $internalPath = trim($internalPath, '/');
+ $inserted = $this->connection->insertIfNotExist('*PREFIX*filecache', [
'storage' => $storageId,
'path' => $internalPath,
'path_hash' => md5($internalPath),
'etag' => '',
'permissions' => 31
], ['storage', 'path_hash']);
- $id = (int)$this->connection->lastInsertId('*PREFIX*filecache');
- $this->fileIds[] = $id;
+ if ($inserted) {
+ $id = (int)$this->connection->lastInsertId('*PREFIX*filecache');
+ $this->fileIds[] = $id;
+ } else {
+ $sql = 'SELECT fileid FROM *PREFIX*filecache WHERE `storage` = ? AND `path_hash` =?';
+ $query = $this->connection->prepare($sql);
+ $query->execute([$storageId, md5($internalPath)]);
+ return (int)$query->fetchColumn();
+ }
return $id;
}
public function testGetMountsForFileIdRootId() {
$user1 = $this->userManager->get('u1');
- $rootId = $this->createCacheEntry('', 2);
-
- $mount1 = new MountPoint($this->getStorage(2, $rootId), '/foo/');
+ list($storage1, $rootId) = $this->getStorage(2);
+ $mount1 = new MountPoint($storage1, '/foo/');
$this->cache->registerMounts($user1, [$mount1]);
public function testGetMountsForFileIdSubFolder() {
$user1 = $this->userManager->get('u1');
- $rootId = $this->createCacheEntry('', 2);
$fileId = $this->createCacheEntry('/foo/bar', 2);
- $mount1 = new MountPoint($this->getStorage(2, $rootId), '/foo/');
+ list($storage1, $rootId) = $this->getStorage(2);
+ $mount1 = new MountPoint($storage1, '/foo/');
$this->cache->registerMounts($user1, [$mount1]);
public function testGetMountsForFileIdSubFolderMount() {
$user1 = $this->userManager->get('u1');
- $this->createCacheEntry('', 2);
+ list($storage1, $rootId) = $this->getStorage(2);
$folderId = $this->createCacheEntry('/foo', 2);
$fileId = $this->createCacheEntry('/foo/bar', 2);
- $mount1 = new MountPoint($this->getStorage(2, $folderId), '/foo/');
+
+ $mount1 = $this->getMockBuilder('\OC\Files\Mount\MountPoint')
+ ->setConstructorArgs([$storage1, '/'])
+ ->setMethods(['getStorageRootId'])
+ ->getMock();
+
+ $mount1->expects($this->any())
+ ->method('getStorageRootId')
+ ->will($this->returnValue($folderId));
$this->cache->registerMounts($user1, [$mount1]);
$this->assertCount(1, $cachedMounts);
- $this->assertEquals('/foo/', $cachedMounts[0]->getMountPoint());
+ $this->assertEquals('/', $cachedMounts[0]->getMountPoint());
$this->assertEquals($user1, $cachedMounts[0]->getUser());
$this->assertEquals($folderId, $cachedMounts[0]->getRootId());
$this->assertEquals(2, $cachedMounts[0]->getStorageId());
+ $this->assertEquals('foo', $cachedMounts[0]->getRootInternalPath());
}
public function testGetMountsForFileIdSubFolderMountOutside() {
$user1 = $this->userManager->get('u1');
- $this->createCacheEntry('', 2);
+ list($storage1, $rootId) = $this->getStorage(2);
$folderId = $this->createCacheEntry('/foo', 2);
$fileId = $this->createCacheEntry('/bar/asd', 2);
- $mount1 = new MountPoint($this->getStorage(2, $folderId), '/foo/');
+ $mount1 = $this->getMockBuilder('\OC\Files\Mount\MountPoint')
+ ->setConstructorArgs([$storage1, '/foo/'])
+ ->setMethods(['getStorageRootId'])
+ ->getMock();
+
+ $mount1->expects($this->any())
+ ->method('getStorageRootId')
+ ->will($this->returnValue($folderId));
+
+ $this->cache->registerMounts($user1, [$mount1]);
$this->cache->registerMounts($user1, [$mount1]);
/** @var \OC\Files\View|\PHPUnit_Framework_MockObject_MockObject */
private $view;
+ /** @var \OCP\Files\Config\IUserMountCache|\PHPUnit_Framework_MockObject_MockObject */
+ private $userMountCache;
+
protected function setUp() {
parent::setUp();
$config = $this->getMockBuilder('\OCP\IConfig')
$this->view = $this->getMockBuilder('\OC\Files\View')
->disableOriginalConstructor()
->getMock();
+ $this->userMountCache = $this->getMockBuilder('\OCP\Files\Config\IUserMountCache')
+ ->disableOriginalConstructor()
+ ->getMock();
}
protected function getMockStorage() {
public function testDelete() {
/** @var \OC\Files\Node\Root|\PHPUnit_Framework_MockObject_MockObject $root */
$root = $this->getMockBuilder('\OC\Files\Node\Root')
- ->setConstructorArgs([$this->manager, $this->view, $this->user])
+ ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache])
->getMock();
$root->expects($this->exactly(2))
$hooksRun++;
};
- $root = new \OC\Files\Node\Root($this->manager, $this->view, $this->user);
+ $root = new \OC\Files\Node\Root($this->manager, $this->view, $this->user, $this->userMountCache);
$root->listen('\OC\Files', 'preDelete', $preListener);
$root->listen('\OC\Files', 'postDelete', $postListener);
public function testDeleteNotPermitted() {
/** @var \OC\Files\Node\Root|\PHPUnit_Framework_MockObject_MockObject $root */
$root = $this->getMockBuilder('\OC\Files\Node\Root')
- ->setConstructorArgs([$this->manager, $this->view, $this->user])
+ ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache])
->getMock();
$root->expects($this->any())
public function testGetContent() {
/** @var \OC\Files\Node\Root|\PHPUnit_Framework_MockObject_MockObject $root */
$root = $this->getMockBuilder('\OC\Files\Node\Root')
- ->setConstructorArgs([$this->manager, $this->view, $this->user])
+ ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache])
->getMock();
$hook = function ($file) {
public function testGetContentNotPermitted() {
/** @var \OC\Files\Node\Root|\PHPUnit_Framework_MockObject_MockObject $root */
$root = $this->getMockBuilder('\OC\Files\Node\Root')
- ->setConstructorArgs([$this->manager, $this->view, $this->user])
+ ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache])
->getMock();
$root->expects($this->any())
public function testPutContent() {
/** @var \OC\Files\Node\Root|\PHPUnit_Framework_MockObject_MockObject $root */
$root = $this->getMockBuilder('\OC\Files\Node\Root')
- ->setConstructorArgs([$this->manager, $this->view, $this->user])
+ ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache])
->getMock();
$root->expects($this->any())
public function testPutContentNotPermitted() {
/** @var \OC\Files\Node\Root|\PHPUnit_Framework_MockObject_MockObject $root */
$root = $this->getMockBuilder('\OC\Files\Node\Root')
- ->setConstructorArgs([$this->manager, $this->view, $this->user])
+ ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache])
->getMock();
$this->view->expects($this->once())
public function testGetMimeType() {
/** @var \OC\Files\Node\Root|\PHPUnit_Framework_MockObject_MockObject $root */
$root = $this->getMockBuilder('\OC\Files\Node\Root')
- ->setConstructorArgs([$this->manager, $this->view, $this->user])
+ ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache])
->getMock();
$this->view->expects($this->once())
fwrite($stream, 'bar');
rewind($stream);
- $root = new \OC\Files\Node\Root($this->manager, $this->view, $this->user);
+ $root = new \OC\Files\Node\Root($this->manager, $this->view, $this->user, $this->userMountCache);
$hook = function ($file) {
throw new \Exception('Hooks are not supposed to be called');
public function testFOpenWrite() {
$stream = fopen('php://memory', 'w+');
- $root = new \OC\Files\Node\Root($this->manager, new $this->view, $this->user);
+ $root = new \OC\Files\Node\Root($this->manager, new $this->view, $this->user, $this->userMountCache);
$hooksCalled = 0;
$hook = function ($file) use (&$hooksCalled) {
* @expectedException \OCP\Files\NotPermittedException
*/
public function testFOpenReadNotPermitted() {
- $root = new \OC\Files\Node\Root($this->manager, $this->view, $this->user);
+ $root = new \OC\Files\Node\Root($this->manager, $this->view, $this->user, $this->userMountCache);
$hook = function ($file) {
throw new \Exception('Hooks are not supposed to be called');
* @expectedException \OCP\Files\NotPermittedException
*/
public function testFOpenReadWriteNoReadPermissions() {
- $root = new \OC\Files\Node\Root($this->manager, $this->view, $this->user);
+ $root = new \OC\Files\Node\Root($this->manager, $this->view, $this->user, $this->userMountCache);
$hook = function () {
throw new \Exception('Hooks are not supposed to be called');
* @expectedException \OCP\Files\NotPermittedException
*/
public function testFOpenReadWriteNoWritePermissions() {
- $root = new \OC\Files\Node\Root($this->manager, new $this->view, $this->user);
+ $root = new \OC\Files\Node\Root($this->manager, new $this->view, $this->user, $this->userMountCache);
$hook = function () {
throw new \Exception('Hooks are not supposed to be called');
public function testCopySameStorage() {
/** @var \OC\Files\Node\Root|\PHPUnit_Framework_MockObject_MockObject $root */
$root = $this->getMockBuilder('\OC\Files\Node\Root')
- ->setConstructorArgs([$this->manager, $this->view, $this->user])
+ ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache])
->getMock();
$this->view->expects($this->any())
public function testCopyNotPermitted() {
/** @var \OC\Files\Node\Root|\PHPUnit_Framework_MockObject_MockObject $root */
$root = $this->getMockBuilder('\OC\Files\Node\Root')
- ->setConstructorArgs([$this->manager, $this->view, $this->user])
+ ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache])
->getMock();
/**
public function testCopyNoParent() {
/** @var \OC\Files\Node\Root|\PHPUnit_Framework_MockObject_MockObject $root */
$root = $this->getMockBuilder('\OC\Files\Node\Root')
- ->setConstructorArgs([$this->manager, $this->view, $this->user])
+ ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache])
->getMock();
$this->view->expects($this->never())
public function testCopyParentIsFile() {
/** @var \OC\Files\Node\Root|\PHPUnit_Framework_MockObject_MockObject $root */
$root = $this->getMockBuilder('\OC\Files\Node\Root')
- ->setConstructorArgs([$this->manager, $this->view, $this->user])
+ ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache])
->getMock();
$this->view->expects($this->never())
public function testMoveSameStorage() {
/** @var \OC\Files\Node\Root|\PHPUnit_Framework_MockObject_MockObject $root */
$root = $this->getMockBuilder('\OC\Files\Node\Root')
- ->setConstructorArgs([$this->manager, $this->view, $this->user])
+ ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache])
->getMock();
$this->view->expects($this->any())
public function testMoveNotPermitted() {
/** @var \OC\Files\Node\Root|\PHPUnit_Framework_MockObject_MockObject $root */
$root = $this->getMockBuilder('\OC\Files\Node\Root')
- ->setConstructorArgs([$this->manager, $this->view, $this->user])
+ ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache])
->getMock();
$this->view->expects($this->any())
public function testMoveNoParent() {
/** @var \OC\Files\Node\Root|\PHPUnit_Framework_MockObject_MockObject $root */
$root = $this->getMockBuilder('\OC\Files\Node\Root')
- ->setConstructorArgs([$this->manager, $this->view, $this->user])
+ ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache])
->getMock();
/**
public function testMoveParentIsFile() {
/** @var \OC\Files\Node\Root|\PHPUnit_Framework_MockObject_MockObject $root */
$root = $this->getMockBuilder('\OC\Files\Node\Root')
- ->setConstructorArgs([$this->manager, $this->view, $this->user])
+ ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache])
->getMock();
$this->view->expects($this->never())
namespace Test\Files\Node;
use OC\Files\Cache\Cache;
+use OC\Files\Cache\CacheEntry;
+use OC\Files\Config\CachedMountInfo;
use OC\Files\FileInfo;
use OC\Files\Mount\Manager;
use OC\Files\Mount\MountPoint;
class FolderTest extends \Test\TestCase {
private $user;
+ /** @var \OCP\Files\Config\IUserMountCache|\PHPUnit_Framework_MockObject_MockObject */
+ private $userMountCache;
+
protected function setUp() {
parent::setUp();
$this->user = new \OC\User\User('', new \Test\Util\User\Dummy);
+ $this->userMountCache = $this->getMockBuilder('\OCP\Files\Config\IUserMountCache')
+ ->disableOriginalConstructor()
+ ->getMock();
}
protected function getMockStorage() {
*/
$view = $this->createMock(View::class);
$root = $this->getMockBuilder(Root::class)
- ->setConstructorArgs([$manager, $view, $this->user])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache])
->getMock();
$root->expects($this->any())
->method('getUser')
* @var \OC\Files\View | \PHPUnit_Framework_MockObject_MockObject $view
*/
$view = $this->createMock(View::class);
- $root = new \OC\Files\Node\Root($manager, $view, $this->user);
+ $root = new \OC\Files\Node\Root($manager, $view, $this->user, $this->userMountCache);
$root->listen('\OC\Files', 'preDelete', $preListener);
$root->listen('\OC\Files', 'postDelete', $postListener);
* @var \OC\Files\View | \PHPUnit_Framework_MockObject_MockObject $view
*/
$view = $this->createMock(View::class);
- $root = $this->getMockBuilder(Root::class)->setConstructorArgs([$manager, $view, $this->user])->getMock();
+ $root = $this->getMockBuilder(Root::class)->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache])->getMock();
$root->expects($this->any())
->method('getUser')
->will($this->returnValue($this->user));
*/
$view = $this->createMock(View::class);
$root = $this->getMockBuilder(Root::class)
- ->setConstructorArgs([$manager, $view, $this->user])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache])
->getMock();
$root->expects($this->any())
->method('getUser')
* @var \OC\Files\View | \PHPUnit_Framework_MockObject_MockObject $view
*/
$view = $this->createMock(View::class);
- $root = $this->getMockBuilder(Root::class)->setConstructorArgs([$manager, $view, $this->user])->getMock();
+ $root = $this->getMockBuilder(Root::class)->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache])->getMock();
$root->expects($this->any())
->method('getUser')
->will($this->returnValue($this->user));
* @var \OC\Files\View | \PHPUnit_Framework_MockObject_MockObject $view
*/
$view = $this->createMock(View::class);
- $root = $this->getMockBuilder(Root::class)->setConstructorArgs([$manager, $view, $this->user])->getMock();
+ $root = $this->getMockBuilder(Root::class)->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache])->getMock();
$root->expects($this->any())
->method('getUser')
->will($this->returnValue($this->user));
* @var \OC\Files\View | \PHPUnit_Framework_MockObject_MockObject $view
*/
$view = $this->createMock(View::class);
- $root = $this->getMockBuilder(Root::class)->setConstructorArgs([$manager, $view, $this->user])->getMock();
+ $root = $this->getMockBuilder(Root::class)->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache])->getMock();
$root->expects($this->any())
->method('getUser')
->will($this->returnValue($this->user));
* @var \OC\Files\View | \PHPUnit_Framework_MockObject_MockObject $view
*/
$view = $this->createMock(View::class);
- $root = $this->getMockBuilder(Root::class)->setConstructorArgs([$manager, $view, $this->user])->getMock();
+ $root = $this->getMockBuilder(Root::class)->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache])->getMock();
$root->expects($this->any())
->method('getUser')
->will($this->returnValue($this->user));
* @var \OC\Files\View | \PHPUnit_Framework_MockObject_MockObject $view
*/
$view = $this->createMock(View::class);
- $root = $this->getMockBuilder(Root::class)->setConstructorArgs([$manager, $view, $this->user])->getMock();
+ $root = $this->getMockBuilder(Root::class)->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache])->getMock();
$root->expects($this->any())
->method('getUser')
->will($this->returnValue($this->user));
* @var \OC\Files\View | \PHPUnit_Framework_MockObject_MockObject $view
*/
$view = $this->createMock(View::class);
- $root = $this->getMockBuilder(Root::class)->setConstructorArgs([$manager, $view, $this->user])->getMock();
+ $root = $this->getMockBuilder(Root::class)->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache])->getMock();
$root->expects($this->any())
->method('getUser')
->will($this->returnValue($this->user));
* @var \OC\Files\View | \PHPUnit_Framework_MockObject_MockObject $view
*/
$view = $this->createMock(View::class);
- $root = $this->getMockBuilder(Root::class)->setConstructorArgs([$manager, $view, $this->user])->getMock();
+ $root = $this->getMockBuilder(Root::class)->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache])->getMock();
$root->expects($this->any())
->method('getUser')
->will($this->returnValue($this->user));
* @var \OC\Files\View | \PHPUnit_Framework_MockObject_MockObject $view
*/
$view = $this->createMock(View::class);
- $root = $this->getMockBuilder(Root::class)->setConstructorArgs([$manager, $view, $this->user])->getMock();
+ $root = $this->getMockBuilder(Root::class)->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache])->getMock();
$root->expects($this->any())
->method('getUser')
->will($this->returnValue($this->user));
* @var \OC\Files\View | \PHPUnit_Framework_MockObject_MockObject $view
*/
$view = $this->createMock(View::class);
- $root = $this->getMockBuilder(Root::class)->setConstructorArgs([$manager, $view, $this->user])->getMock();
+ $root = $this->getMockBuilder(Root::class)->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache])->getMock();
$root->expects($this->any())
->method('getUser')
->will($this->returnValue($this->user));
* @var \OC\Files\View | \PHPUnit_Framework_MockObject_MockObject $view
*/
$view = $this->createMock(View::class);
- $root = $this->getMockBuilder(Root::class)->setMethods(['getUser', 'getMountsIn', 'getMount'])->setConstructorArgs([$manager, $view, $this->user])->getMock();
+ $root = $this->getMockBuilder(Root::class)->setMethods(['getUser', 'getMountsIn', 'getMount'])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache])->getMock();
$root->expects($this->any())
->method('getUser')
->will($this->returnValue($this->user));
* @var \OC\Files\View | \PHPUnit_Framework_MockObject_MockObject $view
*/
$view = $this->createMock(View::class);
- $root = $this->getMockBuilder(Root::class)->setConstructorArgs([$manager, $view, $this->user])->getMock();
+ $root = $this->getMockBuilder(Root::class)->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache])->getMock();
$root->expects($this->any())
->method('getUser')
->will($this->returnValue($this->user));
* @var \OC\Files\View | \PHPUnit_Framework_MockObject_MockObject $view
*/
$view = $this->createMock(View::class);
- $root = $this->getMockBuilder(Root::class)->setConstructorArgs([$manager, $view, $this->user])->getMock();
+ $root = $this->getMockBuilder(Root::class)->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache])->getMock();
$root->expects($this->any())
->method('getUser')
->will($this->returnValue($this->user));
* @var \OC\Files\View | \PHPUnit_Framework_MockObject_MockObject $view
*/
$view = $this->createMock(View::class);
- $root = $this->getMockBuilder(Root::class)->setConstructorArgs([$manager, $view, $this->user])->getMock();
+ $root = $this->getMockBuilder(Root::class)->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache])->getMock();
$root->expects($this->any())
->method('getUser')
->will($this->returnValue($this->user));
* @var \OC\Files\View | \PHPUnit_Framework_MockObject_MockObject $view
*/
$view = $this->createMock(View::class);
- $root = $this->getMockBuilder(Root::class)->setMethods(['getUser', 'getMountsIn', 'getMount'])->setConstructorArgs([$manager, $view, $this->user])->getMock();
- $root->expects($this->any())
- ->method('getUser')
- ->will($this->returnValue($this->user));
+ $root = $this->getMockBuilder(Root::class)->setMethods(['getMountsIn', 'getMount'])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache])->getMock();
$storage = $this->createMock(\OC\Files\Storage\Storage::class);
$mount = new MountPoint($storage, '/bar');
$cache = $this->getMockBuilder(Cache::class)->setConstructorArgs([''])->getMock();
- $view->expects($this->once())
- ->method('getFileInfo')
- ->will($this->returnValue(new FileInfo('/bar/foo/qwerty', null, 'qwerty', ['mimetype' => 'text/plain'], null)));
+ $fileInfo = new CacheEntry(['path' => 'foo/qwerty', 'mimetype' => 'text/plain'], null);
$storage->expects($this->once())
->method('getCache')
->will($this->returnValue($cache));
+ $this->userMountCache->expects($this->any())
+ ->method('getMountsForFileId')
+ ->with(1)
+ ->will($this->returnValue([new CachedMountInfo(
+ $this->user,
+ 1,
+ 0,
+ '/bar/',
+ 1,
+ ''
+ )]));
+
$cache->expects($this->once())
- ->method('getPathById')
- ->with('1')
- ->will($this->returnValue('foo/qwerty'));
+ ->method('get')
+ ->with(1)
+ ->will($this->returnValue($fileInfo));
$root->expects($this->once())
->method('getMountsIn')
* @var \OC\Files\View | \PHPUnit_Framework_MockObject_MockObject $view
*/
$view = $this->createMock(View::class);
- $root = $this->getMockBuilder(Root::class)->setMethods(['getUser', 'getMountsIn', 'getMount'])->setConstructorArgs([$manager, $view, $this->user])->getMock();
- $root->expects($this->any())
- ->method('getUser')
- ->will($this->returnValue($this->user));
+ $root = $this->getMockBuilder(Root::class)->setMethods(['getMountsIn', 'getMount'])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache])->getMock();
$storage = $this->createMock(\OC\Files\Storage\Storage::class);
$mount = new MountPoint($storage, '/bar');
$cache = $this->getMockBuilder(Cache::class)->setConstructorArgs([''])->getMock();
+ $fileInfo = new CacheEntry(['path' => 'foobar', 'mimetype' => 'text/plain'], null);
+
$storage->expects($this->once())
->method('getCache')
->will($this->returnValue($cache));
+ $this->userMountCache->expects($this->any())
+ ->method('getMountsForFileId')
+ ->with(1)
+ ->will($this->returnValue([new CachedMountInfo(
+ $this->user,
+ 1,
+ 0,
+ '/bar/',
+ 1,
+ ''
+ )]));
+
$cache->expects($this->once())
- ->method('getPathById')
- ->with('1')
- ->will($this->returnValue('foobar'));
+ ->method('get')
+ ->with(1)
+ ->will($this->returnValue($fileInfo));
$root->expects($this->once())
->method('getMountsIn')
$node = new \OC\Files\Node\Folder($root, $view, '/bar/foo');
$result = $node->getById(1);
- $this->assertCount(0, $result);
+ $this->assertEquals(0, count($result));
}
public function testGetByIdMultipleStorages() {
* @var \OC\Files\View | \PHPUnit_Framework_MockObject_MockObject $view
*/
$view = $this->createMock(View::class);
- $root = $this->getMockBuilder(Root::class)->setMethods(['getUser', 'getMountsIn', 'getMount'])->setConstructorArgs([$manager, $view, $this->user])->getMock();
- $root->expects($this->any())
- ->method('getUser')
- ->will($this->returnValue($this->user));
+ $root = $this->getMockBuilder(Root::class)->setMethods(['getMountsIn', 'getMount'])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache])->getMock();
$storage = $this->createMock(\OC\Files\Storage\Storage::class);
$mount1 = new MountPoint($storage, '/bar');
$mount2 = new MountPoint($storage, '/bar/foo/asd');
$cache = $this->getMockBuilder(Cache::class)->setConstructorArgs([''])->getMock();
- $view->expects($this->any())
- ->method('getFileInfo')
- ->will($this->returnValue(new FileInfo('/bar/foo/qwerty', null, 'qwerty', ['mimetype' => 'plain'], null)));
+ $fileInfo = new CacheEntry(['path' => 'foo/qwerty', 'mimetype' => 'text/plain'], null);
+
+ $storage->expects($this->once())
+ ->method('getCache')
+ ->will($this->returnValue($cache));
+
+ $this->userMountCache->expects($this->any())
+ ->method('getMountsForFileId')
+ ->with(1)
+ ->will($this->returnValue([
+ new CachedMountInfo(
+ $this->user,
+ 1,
+ 0,
+ '/bar/',
+ 1,
+ ''
+ ),
+ new CachedMountInfo(
+ $this->user,
+ 1,
+ 0,
+ '/bar/foo/asd/',
+ 1,
+ ''
+ )
+ ]));
$storage->expects($this->any())
->method('getCache')
->will($this->returnValue($cache));
$cache->expects($this->any())
- ->method('getPathById')
- ->with('1')
- ->will($this->returnValue('foo/qwerty'));
+ ->method('get')
+ ->with(1)
+ ->will($this->returnValue($fileInfo));
$root->expects($this->any())
->method('getMountsIn')
* @var \OC\Files\View | \PHPUnit_Framework_MockObject_MockObject $view
*/
$view = $this->createMock(View::class);
- $root = $this->getMockBuilder(Root::class)->setMethods(['getUser', 'getMountsIn', 'getMount'])->setConstructorArgs([$manager, $view, $this->user])->getMock();
+ $root = $this->getMockBuilder(Root::class)->setMethods(['getUser', 'getMountsIn', 'getMount'])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache])->getMock();
$view->expects($this->any())
->method('file_exists')
*/
$view = $this->createMock(View::class);
/** @var \PHPUnit_Framework_MockObject_MockObject|\OC\Files\Node\Root $root */
- $root = $this->getMockBuilder(Root::class)->setMethods(['getUser', 'getMountsIn', 'getMount'])->setConstructorArgs([$manager, $view, $this->user])->getMock();
+ $root = $this->getMockBuilder(Root::class)->setMethods(['getUser', 'getMountsIn', 'getMount'])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache])->getMock();
/** @var \PHPUnit_Framework_MockObject_MockObject|\OC\Files\FileInfo $folderInfo */
$folderInfo = $this->getMockBuilder('\OC\Files\FileInfo')
->disableOriginalConstructor()->getMock();
*/
$view = $this->createMock(View::class);
/** @var \PHPUnit_Framework_MockObject_MockObject|\OC\Files\Node\Root $root */
- $root = $this->getMockBuilder(Root::class)->setMethods(['getUser', 'getMountsIn', 'getMount'])->setConstructorArgs([$manager, $view, $this->user])->getMock();
+ $root = $this->getMockBuilder(Root::class)->setMethods(['getUser', 'getMountsIn', 'getMount'])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache])->getMock();
/** @var \PHPUnit_Framework_MockObject_MockObject|\OC\Files\FileInfo $folderInfo */
$folderInfo = $this->getMockBuilder('\OC\Files\FileInfo')
->disableOriginalConstructor()->getMock();
*/
$view = $this->createMock(View::class);
/** @var \PHPUnit_Framework_MockObject_MockObject|\OC\Files\Node\Root $root */
- $root = $this->getMockBuilder(Root::class)->setMethods(['getUser', 'getMountsIn', 'getMount'])->setConstructorArgs([$manager, $view, $this->user])->getMock();
+ $root = $this->getMockBuilder(Root::class)->setMethods(['getUser', 'getMountsIn', 'getMount'])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache])->getMock();
/** @var \PHPUnit_Framework_MockObject_MockObject|\OC\Files\FileInfo $folderInfo */
$folderInfo = $this->getMockBuilder('\OC\Files\FileInfo')
->disableOriginalConstructor()->getMock();
$this->registerMount($this->userId, new Temporary(), '/' . $this->userId . '/files/');
\OC_Util::setupFS($this->userId);
$this->view = new View();
- $this->root = new Root(Filesystem::getMountManager(), $this->view, \OC::$server->getUserManager()->get($this->userId));
+ $this->root = new Root(
+ Filesystem::getMountManager(),
+ $this->view,
+ \OC::$server->getUserManager()->get($this->userId),
+ \OC::$server->getUserMountCache()
+ );
}
public function tearDown() {
$this->loginAsUser($user->getUID());
$this->view = new View();
- $this->root = new Root($manager, $this->view, $user);
+ $this->root = new Root($manager, $this->view, $user, \OC::$server->getUserMountCache());
$storage = new Temporary(array());
$subStorage = new Temporary(array());
$this->storages[] = $storage;
/** @var \OC\Files\Node\Root|\PHPUnit_Framework_MockObject_MockObject */
private $root;
+ /** @var \OCP\Files\Config\IUserMountCache|\PHPUnit_Framework_MockObject_MockObject */
+ private $userMountCache;
protected function setUp() {
parent::setUp();
$this->view = $this->getMockBuilder('\OC\Files\View')
->disableOriginalConstructor()
->getMock();
+ $this->userMountCache = $this->getMockBuilder('\OCP\Files\Config\IUserMountCache')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->root = $this->getMockBuilder('\OC\Files\Node\Root')
- ->setConstructorArgs([$this->manager, $this->view, $this->user])
+ ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache])
->getMock();
}
$hooksRun++;
};
- $root = new \OC\Files\Node\Root($this->manager, $this->view, $this->user);
+ $root = new \OC\Files\Node\Root($this->manager, $this->view, $this->user, $this->userMountCache);
$root->listen('\OC\Files', 'preTouch', $preListener);
$root->listen('\OC\Files', 'postTouch', $postListener);
/** @var \OC\Files\Mount\Manager */
private $manager;
+ /** @var \OCP\Files\Config\IUserMountCache|\PHPUnit_Framework_MockObject_MockObject */
+ private $userMountCache;
protected function setUp() {
parent::setUp();
$this->manager = $this->getMockBuilder('\OC\Files\Mount\Manager')
->disableOriginalConstructor()
->getMock();
+ $this->userMountCache = $this->getMockBuilder('\OCP\Files\Config\IUserMountCache')
+ ->disableOriginalConstructor()
+ ->getMock();
}
protected function getFileInfo($data) {
$view = $this->getMockBuilder('\OC\Files\View')
->disableOriginalConstructor()
->getMock();
- $root = new \OC\Files\Node\Root($this->manager, $view, $this->user);
+ $root = new \OC\Files\Node\Root($this->manager, $view, $this->user, $this->userMountCache);
$view->expects($this->once())
->method('getFileInfo')
$view = $this->getMockBuilder('\OC\Files\View')
->disableOriginalConstructor()
->getMock();
- $root = new \OC\Files\Node\Root($this->manager, $view, $this->user);
+ $root = new \OC\Files\Node\Root($this->manager, $view, $this->user, $this->userMountCache);
$view->expects($this->once())
->method('getFileInfo')
$view = $this->getMockBuilder('\OC\Files\View')
->disableOriginalConstructor()
->getMock();
- $root = new \OC\Files\Node\Root($this->manager, $view, $this->user);
+ $root = new \OC\Files\Node\Root($this->manager, $view, $this->user, $this->userMountCache);
$root->get('/../foo');
}
$view = $this->getMockBuilder('\OC\Files\View')
->disableOriginalConstructor()
->getMock();
- $root = new \OC\Files\Node\Root($this->manager, $view, $this->user);
+ $root = new \OC\Files\Node\Root($this->manager, $view, $this->user, $this->userMountCache);
$root->get('/bar/foo');
}