diff options
author | Robin Appelman <robin@icewind.nl> | 2021-03-19 13:35:37 +0100 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2021-03-19 13:35:37 +0100 |
commit | de713967c0f109b674a96fddbb591a85b3e246bd (patch) | |
tree | 73bb93aec300596fe0e8209e01d9db661b66fa80 /tests/lib/Files | |
parent | a428f7d1e03f62c47d6d7e0d48917ffb3291abce (diff) | |
download | nextcloud-server-de713967c0f109b674a96fddbb591a85b3e246bd.tar.gz nextcloud-server-de713967c0f109b674a96fddbb591a85b3e246bd.zip |
cleanup fileinfo creation
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'tests/lib/Files')
-rw-r--r-- | tests/lib/Files/Node/FolderTest.php | 90 |
1 files changed, 30 insertions, 60 deletions
diff --git a/tests/lib/Files/Node/FolderTest.php b/tests/lib/Files/Node/FolderTest.php index 0dfa9be0271..339a77edcc3 100644 --- a/tests/lib/Files/Node/FolderTest.php +++ b/tests/lib/Files/Node/FolderTest.php @@ -290,38 +290,31 @@ 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); $storage = $this->createMock(Storage::class); $storage->method('getId')->willReturn(''); $cache = $this->getMockBuilder(Cache::class)->setConstructorArgs([$storage])->getMock(); - $storage->expects($this->once()) - ->method('getCache') + $storage->method('getCache') ->willReturn($cache); $mount = $this->createMock(IMountPoint::class); - $mount->expects($this->once()) - ->method('getStorage') + $mount->method('getStorage') ->willReturn($storage); - $mount->expects($this->once()) - ->method('getInternalPath') + $mount->method('getInternalPath') ->willReturn('foo'); - $cache->expects($this->once()) - ->method('searchQuery') + $cache->method('searchQuery') ->willReturn([ new CacheEntry(['fileid' => 3, 'path' => 'foo/qwerty', 'name' => 'qwerty', 'size' => 200, 'mtime' => 55, 'mimetype' => 'text/plain']), ]); - $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); @@ -350,31 +343,25 @@ class FolderTest extends NodeTest { $cache = $this->getMockBuilder(Cache::class)->setConstructorArgs([$storage])->getMock(); $mount = $this->createMock(IMountPoint::class); - $mount->expects($this->once()) - ->method('getStorage') + $mount->method('getStorage') ->willReturn($storage); - $mount->expects($this->once()) - ->method('getInternalPath') + $mount->method('getInternalPath') ->willReturn('files'); - $storage->expects($this->once()) - ->method('getCache') + $storage->method('getCache') ->willReturn($cache); - $cache->expects($this->once()) - ->method('searchQuery') + $cache->method('searchQuery') ->willReturn([ new CacheEntry(['fileid' => 3, 'path' => 'files/foo', 'name' => 'qwerty', 'size' => 200, 'mtime' => 55, 'mimetype' => 'text/plain']), new CacheEntry(['fileid' => 3, 'path' => 'files_trashbin/foo2.d12345', 'name' => 'foo2.d12345', 'size' => 200, 'mtime' => 55, 'mimetype' => 'text/plain']), ]); - $root->expects($this->once()) - ->method('getMountsIn') + $root->method('getMountsIn') ->with('') ->willReturn([]); - $root->expects($this->once()) - ->method('getMount') + $root->method('getMount') ->with('') ->willReturn($mount); @@ -392,38 +379,31 @@ 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); $storage = $this->createMock(Storage::class); $storage->method('getId')->willReturn(''); $cache = $this->getMockBuilder(Cache::class)->setConstructorArgs([$storage])->getMock(); $mount = $this->createMock(IMountPoint::class); - $mount->expects($this->once()) - ->method('getStorage') + $mount->method('getStorage') ->willReturn($storage); - $mount->expects($this->once()) - ->method('getInternalPath') + $mount->method('getInternalPath') ->willReturn(''); - $storage->expects($this->once()) - ->method('getCache') + $storage->method('getCache') ->willReturn($cache); - $cache->expects($this->once()) - ->method('searchQuery') + $cache->method('searchQuery') ->willReturn([ new CacheEntry(['fileid' => 3, 'path' => 'foo/qwerty', 'name' => 'qwerty', 'size' => 200, 'mtime' => 55, 'mimetype' => 'text/plain']), ]); - $root->expects($this->once()) - ->method('getMountsIn') + $root->method('getMountsIn') ->with('/bar') ->willReturn([]); - $root->expects($this->once()) - ->method('getMount') + $root->method('getMount') ->with('/bar') ->willReturn($mount); @@ -453,48 +433,38 @@ class FolderTest extends NodeTest { $subMount = $this->getMockBuilder(MountPoint::class)->setConstructorArgs([null, ''])->getMock(); $mount = $this->createMock(IMountPoint::class); - $mount->expects($this->once()) - ->method('getStorage') + $mount->method('getStorage') ->willReturn($storage); - $mount->expects($this->once()) - ->method('getInternalPath') + $mount->method('getInternalPath') ->willReturn('foo'); - $subMount->expects($this->once()) - ->method('getStorage') + $subMount->method('getStorage') ->willReturn($subStorage); - $subMount->expects($this->once()) - ->method('getMountPoint') + $subMount->method('getMountPoint') ->willReturn('/bar/foo/bar/'); - $storage->expects($this->once()) - ->method('getCache') + $storage->method('getCache') ->willReturn($cache); - $subStorage->expects($this->once()) - ->method('getCache') + $subStorage->method('getCache') ->willReturn($subCache); - $cache->expects($this->once()) - ->method('searchQuery') + $cache->method('searchQuery') ->willReturn([ new CacheEntry(['fileid' => 3, 'path' => 'foo/qwerty', 'name' => 'qwerty', 'size' => 200, 'mtime' => 55, 'mimetype' => 'text/plain']), ]); - $subCache->expects($this->once()) - ->method('searchQuery') + $subCache->method('searchQuery') ->willReturn([ new CacheEntry(['fileid' => 4, 'path' => 'asd/qweasd', 'name' => 'qweasd', 'size' => 200, 'mtime' => 55, 'mimetype' => 'text/plain']), ]); - $root->expects($this->once()) - ->method('getMountsIn') + $root->method('getMountsIn') ->with('/bar/foo') ->willReturn([$subMount]); - $root->expects($this->once()) - ->method('getMount') + $root->method('getMount') ->with('/bar/foo') ->willReturn($mount); |