diff options
author | John Molakvoæ <skjnldsv@users.noreply.github.com> | 2021-08-09 19:27:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-09 19:27:23 +0200 |
commit | 67e6468b9e5a6fb30638158c7bd558307d5ff747 (patch) | |
tree | a57b73ca712433c7cd42778a4fea6a52cfd6be70 /tests | |
parent | f5604194bc1bfb22aae191a9dda579cc5221f4ef (diff) | |
parent | 5c2e7c7d284d92a802a9a673136383a991b36ee6 (diff) | |
download | nextcloud-server-67e6468b9e5a6fb30638158c7bd558307d5ff747.tar.gz nextcloud-server-67e6468b9e5a6fb30638158c7bd558307d5ff747.zip |
Merge pull request #28220 from nextcloud/get-by-id-multiple-mounts-single-storage
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); |