aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/Files/Node/FolderTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/Files/Node/FolderTest.php')
-rw-r--r--tests/lib/Files/Node/FolderTest.php65
1 files changed, 34 insertions, 31 deletions
diff --git a/tests/lib/Files/Node/FolderTest.php b/tests/lib/Files/Node/FolderTest.php
index e3edf202f8e..53e8f07a0d3 100644
--- a/tests/lib/Files/Node/FolderTest.php
+++ b/tests/lib/Files/Node/FolderTest.php
@@ -21,12 +21,15 @@ use OC\Files\Search\SearchBinaryOperator;
use OC\Files\Search\SearchComparison;
use OC\Files\Search\SearchOrder;
use OC\Files\Search\SearchQuery;
+use OC\Files\Storage\Storage;
use OC\Files\Storage\Temporary;
use OC\Files\Storage\Wrapper\Jail;
+use OCP\Constants;
use OCP\Files\Cache\ICacheEntry;
use OCP\Files\IRootFolder;
use OCP\Files\Mount\IMountPoint;
use OCP\Files\NotFoundException;
+use OCP\Files\NotPermittedException;
use OCP\Files\Search\ISearchBinaryOperator;
use OCP\Files\Search\ISearchComparison;
use OCP\Files\Search\ISearchOrder;
@@ -40,7 +43,7 @@ use PHPUnit\Framework\MockObject\MockObject;
*
* @package Test\Files\Node
*/
-class FolderTest extends NodeTest {
+class FolderTest extends NodeTestCase {
protected function createTestNode($root, $view, $path, array $data = [], $internalPath = '', $storage = null) {
$view->expects($this->any())
->method('getRoot')
@@ -150,7 +153,7 @@ class FolderTest extends NodeTest {
$root->method('get')
->with('/bar/foo/asd')
- ->will($this->throwException(new NotFoundException()));
+ ->willThrowException(new NotFoundException());
$node = new Folder($root, $view, '/bar/foo');
$this->assertFalse($node->nodeExists('asd'));
@@ -168,7 +171,7 @@ class FolderTest extends NodeTest {
$view->method('getFileInfo')
->with('/bar/foo')
- ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL]));
+ ->willReturn($this->getFileInfo(['permissions' => Constants::PERMISSION_ALL]));
$view->method('mkdir')
->with('/bar/foo/asd')
@@ -192,7 +195,7 @@ class FolderTest extends NodeTest {
$view->method('getFileInfo')
->with('/foobar')
- ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL]));
+ ->willReturn($this->getFileInfo(['permissions' => Constants::PERMISSION_ALL]));
$view->method('mkdir')
->with('/foobar/asd/sdf')
@@ -206,7 +209,7 @@ class FolderTest extends NodeTest {
public function testNewFolderNotPermitted(): void {
- $this->expectException(\OCP\Files\NotPermittedException::class);
+ $this->expectException(NotPermittedException::class);
$manager = $this->createMock(Manager::class);
$view = $this->getRootViewMock();
@@ -218,7 +221,7 @@ class FolderTest extends NodeTest {
$view->method('getFileInfo')
->with('/bar/foo')
- ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_READ]));
+ ->willReturn($this->getFileInfo(['permissions' => Constants::PERMISSION_READ]));
$node = new Folder($root, $view, '/bar/foo');
$node->newFolder('asd');
@@ -236,21 +239,21 @@ class FolderTest extends NodeTest {
$view->method('getFileInfo')
->with('/bar/foo')
- ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL]));
+ ->willReturn($this->getFileInfo(['permissions' => Constants::PERMISSION_ALL]));
$view->method('touch')
->with('/bar/foo/asd')
->willReturn(true);
$node = new Folder($root, $view, '/bar/foo');
- $child = new \OC\Files\Node\File($root, $view, '/bar/foo/asd', null, $node);
+ $child = new File($root, $view, '/bar/foo/asd', null, $node);
$result = $node->newFile('asd');
$this->assertEquals($child, $result);
}
public function testNewFileNotPermitted(): void {
- $this->expectException(\OCP\Files\NotPermittedException::class);
+ $this->expectException(NotPermittedException::class);
$manager = $this->createMock(Manager::class);
$view = $this->getRootViewMock();
@@ -262,7 +265,7 @@ class FolderTest extends NodeTest {
$view->method('getFileInfo')
->with('/bar/foo')
- ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_READ]));
+ ->willReturn($this->getFileInfo(['permissions' => Constants::PERMISSION_READ]));
$node = new Folder($root, $view, '/bar/foo');
$node->newFile('asd');
@@ -337,7 +340,7 @@ class FolderTest extends NodeTest {
$manager = $this->createMock(Manager::class);
$view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
- ->setMethods(['getUser', 'getMountsIn', 'getMount'])
+ ->onlyMethods(['getUser', 'getMountsIn', 'getMount'])
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
$root->expects($this->any())
@@ -499,10 +502,10 @@ class FolderTest extends NodeTest {
$manager = $this->createMock(Manager::class);
$view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
- ->setMethods(['getMountsIn', 'getMount'])
+ ->onlyMethods(['getMountsIn', 'getMount'])
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
- $storage = $this->createMock(\OC\Files\Storage\Storage::class);
+ $storage = $this->createMock(Storage::class);
$mount = new MountPoint($storage, '/bar');
$storage->method('getId')->willReturn('');
$cache = $this->getMockBuilder(Cache::class)->setConstructorArgs([$storage])->getMock();
@@ -548,10 +551,10 @@ class FolderTest extends NodeTest {
$manager = $this->createMock(Manager::class);
$view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
- ->setMethods(['getMountsIn', 'getMount'])
+ ->onlyMethods(['getMountsIn', 'getMount'])
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
- $storage = $this->createMock(\OC\Files\Storage\Storage::class);
+ $storage = $this->createMock(Storage::class);
$mount = new MountPoint($storage, '/bar');
$storage->method('getId')->willReturn('');
$cache = $this->getMockBuilder(Cache::class)->setConstructorArgs([$storage])->getMock();
@@ -593,10 +596,10 @@ class FolderTest extends NodeTest {
$manager = $this->createMock(Manager::class);
$view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
- ->setMethods(['getMountsIn', 'getMount'])
+ ->onlyMethods(['getMountsIn', 'getMount'])
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
- $storage = $this->createMock(\OC\Files\Storage\Storage::class);
+ $storage = $this->createMock(Storage::class);
$mount = new MountPoint($storage, '/bar');
$storage->method('getId')->willReturn('');
$cache = $this->getMockBuilder(Cache::class)->setConstructorArgs([$storage])->getMock();
@@ -637,10 +640,10 @@ class FolderTest extends NodeTest {
$manager = $this->createMock(Manager::class);
$view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
- ->setMethods(['getMountsIn', 'getMount'])
+ ->onlyMethods(['getMountsIn', 'getMount'])
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
- $storage = $this->createMock(\OC\Files\Storage\Storage::class);
+ $storage = $this->createMock(Storage::class);
$mount1 = new MountPoint($storage, '/bar');
$mount2 = new MountPoint($storage, '/bar/foo/asd');
$storage->method('getId')->willReturn('');
@@ -681,7 +684,7 @@ class FolderTest extends NodeTest {
$this->assertEquals('/bar/foo/asd/foo/qwerty', $result[1]->getPath());
}
- public function uniqueNameProvider() {
+ public static function uniqueNameProvider(): array {
return [
// input, existing, expected
['foo', [], 'foo'],
@@ -698,7 +701,7 @@ class FolderTest extends NodeTest {
$folderPath = '/bar/foo';
$view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
- ->setMethods(['getUser', 'getMountsIn', 'getMount'])
+ ->onlyMethods(['getUser', 'getMountsIn', 'getMount'])
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
@@ -723,7 +726,7 @@ class FolderTest extends NodeTest {
$view = $this->getRootViewMock();
/** @var \PHPUnit\Framework\MockObject\MockObject|\OC\Files\Node\Root $root */
$root = $this->getMockBuilder(Root::class)
- ->setMethods(['getUser', 'getMountsIn', 'getMount'])
+ ->onlyMethods(['getUser', 'getMountsIn', 'getMount'])
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
/** @var \PHPUnit\Framework\MockObject\MockObject|\OC\Files\FileInfo $folderInfo */
@@ -753,14 +756,14 @@ class FolderTest extends NodeTest {
'mtime' => $baseTime,
'mimetype' => 'text/plain',
'size' => 3,
- 'permissions' => \OCP\Constants::PERMISSION_ALL,
+ 'permissions' => Constants::PERMISSION_ALL,
]);
$id2 = $cache->put('bar/foo/old.txt', [
'storage_mtime' => $baseTime - 100,
'mtime' => $baseTime - 100,
'mimetype' => 'text/plain',
'size' => 3,
- 'permissions' => \OCP\Constants::PERMISSION_READ,
+ 'permissions' => Constants::PERMISSION_READ,
]);
$cache->put('bar/asd/outside.txt', [
'storage_mtime' => $baseTime,
@@ -773,7 +776,7 @@ class FolderTest extends NodeTest {
'mtime' => $baseTime - 600,
'mimetype' => 'text/plain',
'size' => 3,
- 'permissions' => \OCP\Constants::PERMISSION_ALL,
+ 'permissions' => Constants::PERMISSION_ALL,
]);
$node = new Folder($root, $view, $folderPath, $folderInfo);
@@ -792,7 +795,7 @@ class FolderTest extends NodeTest {
$view = $this->getRootViewMock();
/** @var \PHPUnit\Framework\MockObject\MockObject|\OC\Files\Node\Root $root */
$root = $this->getMockBuilder(Root::class)
- ->setMethods(['getUser', 'getMountsIn', 'getMount'])
+ ->onlyMethods(['getUser', 'getMountsIn', 'getMount'])
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
/** @var \PHPUnit\Framework\MockObject\MockObject|\OC\Files\FileInfo $folderInfo */
@@ -830,7 +833,7 @@ class FolderTest extends NodeTest {
'mimetype' => 'text/plain',
'size' => 3,
'parent' => $id1,
- 'permissions' => \OCP\Constants::PERMISSION_ALL,
+ 'permissions' => Constants::PERMISSION_ALL,
]);
$id3 = $cache->put('bar/foo/folder/asd.txt', [
'storage_mtime' => $baseTime - 100,
@@ -838,7 +841,7 @@ class FolderTest extends NodeTest {
'mimetype' => 'text/plain',
'size' => 3,
'parent' => $id1,
- 'permissions' => \OCP\Constants::PERMISSION_ALL,
+ 'permissions' => Constants::PERMISSION_ALL,
]);
$node = new Folder($root, $view, $folderPath, $folderInfo);
@@ -859,7 +862,7 @@ class FolderTest extends NodeTest {
$view = $this->getRootViewMock();
/** @var \PHPUnit\Framework\MockObject\MockObject|\OC\Files\Node\Root $root */
$root = $this->getMockBuilder(Root::class)
- ->setMethods(['getUser', 'getMountsIn', 'getMount'])
+ ->onlyMethods(['getUser', 'getMountsIn', 'getMount'])
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
/** @var \PHPUnit\Framework\MockObject\MockObject|\OC\Files\FileInfo $folderInfo */
@@ -891,7 +894,7 @@ class FolderTest extends NodeTest {
'mtime' => $baseTime,
'mimetype' => 'text/plain',
'size' => 3,
- 'permissions' => \OCP\Constants::PERMISSION_ALL,
+ 'permissions' => Constants::PERMISSION_ALL,
]);
$cache->put('outside.txt', [
@@ -910,7 +913,7 @@ class FolderTest extends NodeTest {
$this->assertEquals([$id1], $ids);
}
- public function offsetLimitProvider() {
+ public static function offsetLimitProvider(): array {
return [
[0, 10, ['/bar/foo/foo1', '/bar/foo/foo2', '/bar/foo/foo3', '/bar/foo/foo4', '/bar/foo/sub1/foo5', '/bar/foo/sub1/foo6', '/bar/foo/sub2/foo7', '/bar/foo/sub2/foo8'], []],
[0, 5, ['/bar/foo/foo1', '/bar/foo/foo2', '/bar/foo/foo3', '/bar/foo/foo4', '/bar/foo/sub1/foo5'], []],