diff options
author | Robin Appelman <robin@icewind.nl> | 2021-07-28 18:03:33 +0300 |
---|---|---|
committer | backportbot[bot] <backportbot[bot]@users.noreply.github.com> | 2021-08-09 20:29:40 +0300 |
commit | 8a6e3e6aca53fea2683de1408bf5904b097cdc0f (patch) | |
tree | 79cbadf4c8e4c70b24624ef1b460e7791546e5fc /tests | |
parent | 876545502cc290cdb23625e9253b821b336e6830 (diff) |
fix Folder->getById() when a single storage is mounted multiple times
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/Files/Node/FolderTest.php | 98 |
1 files changed, 30 insertions, 68 deletions
diff --git a/tests/lib/Files/Node/FolderTest.php b/tests/lib/Files/Node/FolderTest.php index 72bf70a68b7..94bcac4aa00 100644 --- a/tests/lib/Files/Node/FolderTest.php +++ b/tests/lib/Files/Node/FolderTest.php @@ -99,8 +99,7 @@ class FolderTest extends NodeTest { ->method('getUser') ->willReturn($this->user); - $root->expects($this->once()) - ->method('get') + $root->method('get') ->with('/bar/foo/asd'); $node = new Folder($root, $view, '/bar/foo'); @@ -122,8 +121,7 @@ class FolderTest extends NodeTest { $child = new Folder($root, $view, '/bar/foo/asd'); - $root->expects($this->once()) - ->method('get') + $root->method('get') ->with('/bar/foo/asd') ->willReturn($child); @@ -144,8 +142,7 @@ class FolderTest extends NodeTest { ->method('getUser') ->willReturn($this->user); - $root->expects($this->once()) - ->method('get') + $root->method('get') ->with('/bar/foo/asd') ->will($this->throwException(new NotFoundException())); @@ -166,13 +163,11 @@ class FolderTest extends NodeTest { ->method('getUser') ->willReturn($this->user); - $view->expects($this->once()) - ->method('getFileInfo') + $view->method('getFileInfo') ->with('/bar/foo') ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL])); - $view->expects($this->once()) - ->method('mkdir') + $view->method('mkdir') ->with('/bar/foo/asd') ->willReturn(true); @@ -194,12 +189,10 @@ class FolderTest extends NodeTest { $root = $this->getMockBuilder(Root::class) ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager]) ->getMock(); - $root->expects($this->any()) - ->method('getUser') + $root->method('getUser') ->willReturn($this->user); - $view->expects($this->once()) - ->method('getFileInfo') + $view->method('getFileInfo') ->with('/bar/foo') ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_READ])); @@ -220,13 +213,11 @@ class FolderTest extends NodeTest { ->method('getUser') ->willReturn($this->user); - $view->expects($this->once()) - ->method('getFileInfo') + $view->method('getFileInfo') ->with('/bar/foo') ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL])); - $view->expects($this->once()) - ->method('touch') + $view->method('touch') ->with('/bar/foo/asd') ->willReturn(true); @@ -248,12 +239,10 @@ class FolderTest extends NodeTest { $root = $this->getMockBuilder(Root::class) ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager]) ->getMock(); - $root->expects($this->any()) - ->method('getUser') + $root->method('getUser') ->willReturn($this->user); - $view->expects($this->once()) - ->method('getFileInfo') + $view->method('getFileInfo') ->with('/bar/foo') ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_READ])); @@ -270,12 +259,10 @@ class FolderTest extends NodeTest { $root = $this->getMockBuilder(Root::class) ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager]) ->getMock(); - $root->expects($this->any()) - ->method('getUser') + $root->method('getUser') ->willReturn($this->user); - $view->expects($this->once()) - ->method('free_space') + $view->method('free_space') ->with('/bar/foo') ->willReturn(100); @@ -501,8 +488,7 @@ class FolderTest extends NodeTest { $fileInfo = new CacheEntry(['path' => 'foo/qwerty', 'mimetype' => 'text/plain'], null); - $storage->expects($this->once()) - ->method('getCache') + $storage->method('getCache') ->willReturn($cache); $this->userMountCache->expects($this->any()) @@ -517,18 +503,15 @@ class FolderTest extends NodeTest { '' )]); - $cache->expects($this->once()) - ->method('get') + $cache->method('get') ->with(1) ->willReturn($fileInfo); - $root->expects($this->once()) - ->method('getMountsIn') + $root->method('getMountsIn') ->with('/bar/foo') ->willReturn([]); - $root->expects($this->once()) - ->method('getMount') + $root->method('getMount') ->with('/bar/foo') ->willReturn($mount); @@ -555,8 +538,7 @@ class FolderTest extends NodeTest { $fileInfo = new CacheEntry(['path' => '', 'mimetype' => 'text/plain'], null); - $storage->expects($this->once()) - ->method('getCache') + $storage->method('getCache') ->willReturn($cache); $this->userMountCache->expects($this->any()) @@ -571,13 +553,11 @@ class FolderTest extends NodeTest { '' )]); - $cache->expects($this->once()) - ->method('get') + $cache->method('get') ->with(1) ->willReturn($fileInfo); - $root->expects($this->once()) - ->method('getMount') + $root->method('getMount') ->with('/bar') ->willReturn($mount); @@ -604,8 +584,7 @@ class FolderTest extends NodeTest { $fileInfo = new CacheEntry(['path' => 'foobar', 'mimetype' => 'text/plain'], null); - $storage->expects($this->once()) - ->method('getCache') + $storage->method('getCache') ->willReturn($cache); $this->userMountCache->expects($this->any()) @@ -620,18 +599,15 @@ class FolderTest extends NodeTest { '' )]); - $cache->expects($this->once()) - ->method('get') + $cache->method('get') ->with(1) ->willReturn($fileInfo); - $root->expects($this->once()) - ->method('getMountsIn') + $root->method('getMountsIn') ->with('/bar/foo') ->willReturn([]); - $root->expects($this->once()) - ->method('getMount') + $root->method('getMount') ->with('/bar/foo') ->willReturn($mount); @@ -658,12 +634,10 @@ class FolderTest extends NodeTest { $fileInfo = new CacheEntry(['path' => 'foo/qwerty', 'mimetype' => 'text/plain'], null); - $storage->expects($this->exactly(2)) - ->method('getCache') + $storage->method('getCache') ->willReturn($cache); - $this->userMountCache->expects($this->any()) - ->method('getMountsForFileId') + $this->userMountCache->method('getMountsForFileId') ->with(1) ->willReturn([ new CachedMountInfo( @@ -674,32 +648,20 @@ class FolderTest extends NodeTest { 1, '' ), - new CachedMountInfo( - $this->user, - 1, - 0, - '/bar/foo/asd/', - 1, - '' - ), ]); - $storage->expects($this->any()) - ->method('getCache') + $storage->method('getCache') ->willReturn($cache); - $cache->expects($this->any()) - ->method('get') + $cache->method('get') ->with(1) ->willReturn($fileInfo); - $root->expects($this->any()) - ->method('getMountsIn') + $root->method('getMountsIn') ->with('/bar/foo') ->willReturn([$mount2]); - $root->expects($this->once()) - ->method('getMount') + $root->method('getMount') ->with('/bar/foo') ->willReturn($mount1); |