Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2021-07-28 18:03:33 +0300
committerJulius Härtl <jus@bitgrid.net>2021-08-11 10:05:44 +0300
commita4cdebec622dcd73144f5c7d1500869220d032c2 (patch)
tree69fbe4ac0072bf83e8bb07fa096154413c6fde40 /tests
parentd47a26d9a86de61ea83fd59d3df14b3f8a594077 (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.php98
1 files changed, 30 insertions, 68 deletions
diff --git a/tests/lib/Files/Node/FolderTest.php b/tests/lib/Files/Node/FolderTest.php
index 1d541556c0b..be451063b4f 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);
@@ -502,8 +489,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())
@@ -518,18 +504,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);
@@ -556,8 +539,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())
@@ -572,13 +554,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);
@@ -605,8 +585,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())
@@ -621,18 +600,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);
@@ -659,12 +635,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(
@@ -675,32 +649,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);