aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/Files/Node
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/Files/Node')
-rw-r--r--tests/lib/Files/Node/FileTest.php73
-rw-r--r--tests/lib/Files/Node/FolderTest.php41
-rw-r--r--tests/lib/Files/Node/HookConnectorTest.php64
-rw-r--r--tests/lib/Files/Node/IntegrationTest.php5
-rw-r--r--tests/lib/Files/Node/NodeTestCase.php95
-rw-r--r--tests/lib/Files/Node/RootTest.php24
6 files changed, 160 insertions, 142 deletions
diff --git a/tests/lib/Files/Node/FileTest.php b/tests/lib/Files/Node/FileTest.php
index 74a23520344..f3d893d5af2 100644
--- a/tests/lib/Files/Node/FileTest.php
+++ b/tests/lib/Files/Node/FileTest.php
@@ -7,7 +7,10 @@
namespace Test\Files\Node;
+use OC\Files\Node\File;
use OC\Files\Node\Root;
+use OCP\Constants;
+use OCP\Files\NotPermittedException;
/**
* Class FileTest
@@ -19,9 +22,9 @@ use OC\Files\Node\Root;
class FileTest extends NodeTestCase {
protected function createTestNode($root, $view, $path, array $data = [], $internalPath = '', $storage = null) {
if ($data || $internalPath || $storage) {
- return new \OC\Files\Node\File($root, $view, $path, $this->getFileInfo($data, $internalPath, $storage));
+ return new File($root, $view, $path, $this->getFileInfo($data, $internalPath, $storage));
} else {
- return new \OC\Files\Node\File($root, $view, $path);
+ return new File($root, $view, $path);
}
}
@@ -43,7 +46,7 @@ class FileTest extends NodeTestCase {
->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->cacheFactory])
->getMock();
- $hook = function ($file) {
+ $hook = function ($file): void {
throw new \Exception('Hooks are not supposed to be called');
};
@@ -58,15 +61,15 @@ class FileTest extends NodeTestCase {
$this->view->expects($this->once())
->method('getFileInfo')
->with('/bar/foo')
- ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_READ]));
+ ->willReturn($this->getFileInfo(['permissions' => Constants::PERMISSION_READ]));
- $node = new \OC\Files\Node\File($root, $this->view, '/bar/foo');
+ $node = new File($root, $this->view, '/bar/foo');
$this->assertEquals('bar', $node->getContent());
}
public function testGetContentNotPermitted(): void {
- $this->expectException(\OCP\Files\NotPermittedException::class);
+ $this->expectException(NotPermittedException::class);
/** @var \OC\Files\Node\Root|\PHPUnit\Framework\MockObject\MockObject $root */
$root = $this->getMockBuilder(Root::class)
@@ -82,7 +85,7 @@ class FileTest extends NodeTestCase {
->with('/bar/foo')
->willReturn($this->getFileInfo(['permissions' => 0]));
- $node = new \OC\Files\Node\File($root, $this->view, '/bar/foo');
+ $node = new File($root, $this->view, '/bar/foo');
$node->getContent();
}
@@ -99,20 +102,20 @@ class FileTest extends NodeTestCase {
$this->view->expects($this->once())
->method('getFileInfo')
->with('/bar/foo')
- ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL]));
+ ->willReturn($this->getFileInfo(['permissions' => Constants::PERMISSION_ALL]));
$this->view->expects($this->once())
->method('file_put_contents')
->with('/bar/foo', 'bar')
->willReturn(true);
- $node = new \OC\Files\Node\File($root, $this->view, '/bar/foo');
+ $node = new File($root, $this->view, '/bar/foo');
$node->putContent('bar');
}
public function testPutContentNotPermitted(): void {
- $this->expectException(\OCP\Files\NotPermittedException::class);
+ $this->expectException(NotPermittedException::class);
/** @var \OC\Files\Node\Root|\PHPUnit\Framework\MockObject\MockObject $root */
$root = $this->getMockBuilder(Root::class)
@@ -122,9 +125,9 @@ class FileTest extends NodeTestCase {
$this->view->expects($this->once())
->method('getFileInfo')
->with('/bar/foo')
- ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_READ]));
+ ->willReturn($this->getFileInfo(['permissions' => Constants::PERMISSION_READ]));
- $node = new \OC\Files\Node\File($root, $this->view, '/bar/foo');
+ $node = new File($root, $this->view, '/bar/foo');
$node->putContent('bar');
}
@@ -139,7 +142,7 @@ class FileTest extends NodeTestCase {
->with('/bar/foo')
->willReturn($this->getFileInfo(['mimetype' => 'text/plain']));
- $node = new \OC\Files\Node\File($root, $this->view, '/bar/foo');
+ $node = new File($root, $this->view, '/bar/foo');
$this->assertEquals('text/plain', $node->getMimeType());
}
@@ -148,7 +151,7 @@ class FileTest extends NodeTestCase {
fwrite($stream, 'bar');
rewind($stream);
- $root = new \OC\Files\Node\Root(
+ $root = new Root(
$this->manager,
$this->view,
$this->user,
@@ -159,7 +162,7 @@ class FileTest extends NodeTestCase {
$this->cacheFactory,
);
- $hook = function ($file) {
+ $hook = function ($file): void {
throw new \Exception('Hooks are not supposed to be called');
};
@@ -174,9 +177,9 @@ class FileTest extends NodeTestCase {
$this->view->expects($this->once())
->method('getFileInfo')
->with('/bar/foo')
- ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL]));
+ ->willReturn($this->getFileInfo(['permissions' => Constants::PERMISSION_ALL]));
- $node = new \OC\Files\Node\File($root, $this->view, '/bar/foo');
+ $node = new File($root, $this->view, '/bar/foo');
$fh = $node->fopen('r');
$this->assertEquals($stream, $fh);
$this->assertEquals('bar', fread($fh, 3));
@@ -185,7 +188,7 @@ class FileTest extends NodeTestCase {
public function testFOpenWrite(): void {
$stream = fopen('php://memory', 'w+');
- $root = new \OC\Files\Node\Root(
+ $root = new Root(
$this->manager,
$this->view,
$this->user,
@@ -196,7 +199,7 @@ class FileTest extends NodeTestCase {
$this->cacheFactory,
);
$hooksCalled = 0;
- $hook = function ($file) use (&$hooksCalled) {
+ $hook = function ($file) use (&$hooksCalled): void {
$hooksCalled++;
};
@@ -211,9 +214,9 @@ class FileTest extends NodeTestCase {
$this->view->expects($this->once())
->method('getFileInfo')
->with('/bar/foo')
- ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL]));
+ ->willReturn($this->getFileInfo(['permissions' => Constants::PERMISSION_ALL]));
- $node = new \OC\Files\Node\File($root, $this->view, '/bar/foo');
+ $node = new File($root, $this->view, '/bar/foo');
$fh = $node->fopen('w');
$this->assertEquals($stream, $fh);
fwrite($fh, 'bar');
@@ -224,9 +227,9 @@ class FileTest extends NodeTestCase {
public function testFOpenReadNotPermitted(): void {
- $this->expectException(\OCP\Files\NotPermittedException::class);
+ $this->expectException(NotPermittedException::class);
- $root = new \OC\Files\Node\Root(
+ $root = new Root(
$this->manager,
$this->view,
$this->user,
@@ -236,7 +239,7 @@ class FileTest extends NodeTestCase {
$this->eventDispatcher,
$this->cacheFactory,
);
- $hook = function ($file) {
+ $hook = function ($file): void {
throw new \Exception('Hooks are not supposed to be called');
};
@@ -245,15 +248,15 @@ class FileTest extends NodeTestCase {
->with('/bar/foo')
->willReturn($this->getFileInfo(['permissions' => 0]));
- $node = new \OC\Files\Node\File($root, $this->view, '/bar/foo');
+ $node = new File($root, $this->view, '/bar/foo');
$node->fopen('r');
}
public function testFOpenReadWriteNoReadPermissions(): void {
- $this->expectException(\OCP\Files\NotPermittedException::class);
+ $this->expectException(NotPermittedException::class);
- $root = new \OC\Files\Node\Root(
+ $root = new Root(
$this->manager,
$this->view,
$this->user,
@@ -263,24 +266,24 @@ class FileTest extends NodeTestCase {
$this->eventDispatcher,
$this->cacheFactory,
);
- $hook = function () {
+ $hook = function (): void {
throw new \Exception('Hooks are not supposed to be called');
};
$this->view->expects($this->once())
->method('getFileInfo')
->with('/bar/foo')
- ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_UPDATE]));
+ ->willReturn($this->getFileInfo(['permissions' => Constants::PERMISSION_UPDATE]));
- $node = new \OC\Files\Node\File($root, $this->view, '/bar/foo');
+ $node = new File($root, $this->view, '/bar/foo');
$node->fopen('w');
}
public function testFOpenReadWriteNoWritePermissions(): void {
- $this->expectException(\OCP\Files\NotPermittedException::class);
+ $this->expectException(NotPermittedException::class);
- $root = new \OC\Files\Node\Root(
+ $root = new Root(
$this->manager,
$this->view,
$this->user,
@@ -290,16 +293,16 @@ class FileTest extends NodeTestCase {
$this->eventDispatcher,
$this->cacheFactory,
);
- $hook = function () {
+ $hook = function (): void {
throw new \Exception('Hooks are not supposed to be called');
};
$this->view->expects($this->once())
->method('getFileInfo')
->with('/bar/foo')
- ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_READ]));
+ ->willReturn($this->getFileInfo(['permissions' => Constants::PERMISSION_READ]));
- $node = new \OC\Files\Node\File($root, $this->view, '/bar/foo');
+ $node = new File($root, $this->view, '/bar/foo');
$node->fopen('w');
}
}
diff --git a/tests/lib/Files/Node/FolderTest.php b/tests/lib/Files/Node/FolderTest.php
index 25f555e7068..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;
@@ -150,7 +153,7 @@ class FolderTest extends NodeTestCase {
$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 NodeTestCase {
$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 NodeTestCase {
$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 NodeTestCase {
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 NodeTestCase {
$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 NodeTestCase {
$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 NodeTestCase {
$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');
@@ -502,7 +505,7 @@ class FolderTest extends NodeTestCase {
->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();
@@ -551,7 +554,7 @@ class FolderTest extends NodeTestCase {
->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();
@@ -596,7 +599,7 @@ class FolderTest extends NodeTestCase {
->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();
@@ -640,7 +643,7 @@ class FolderTest extends NodeTestCase {
->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('');
@@ -753,14 +756,14 @@ class FolderTest extends NodeTestCase {
'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 NodeTestCase {
'mtime' => $baseTime - 600,
'mimetype' => 'text/plain',
'size' => 3,
- 'permissions' => \OCP\Constants::PERMISSION_ALL,
+ 'permissions' => Constants::PERMISSION_ALL,
]);
$node = new Folder($root, $view, $folderPath, $folderInfo);
@@ -830,7 +833,7 @@ class FolderTest extends NodeTestCase {
'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 NodeTestCase {
'mimetype' => 'text/plain',
'size' => 3,
'parent' => $id1,
- 'permissions' => \OCP\Constants::PERMISSION_ALL,
+ 'permissions' => Constants::PERMISSION_ALL,
]);
$node = new Folder($root, $view, $folderPath, $folderInfo);
@@ -891,7 +894,7 @@ class FolderTest extends NodeTestCase {
'mtime' => $baseTime,
'mimetype' => 'text/plain',
'size' => 3,
- 'permissions' => \OCP\Constants::PERMISSION_ALL,
+ 'permissions' => Constants::PERMISSION_ALL,
]);
$cache->put('outside.txt', [
diff --git a/tests/lib/Files/Node/HookConnectorTest.php b/tests/lib/Files/Node/HookConnectorTest.php
index 87e83fd0a3b..0b7d26fd24d 100644
--- a/tests/lib/Files/Node/HookConnectorTest.php
+++ b/tests/lib/Files/Node/HookConnectorTest.php
@@ -15,6 +15,7 @@ use OC\Files\View;
use OC\Memcache\ArrayCache;
use OCP\EventDispatcher\GenericEvent as APIGenericEvent;
use OCP\EventDispatcher\IEventDispatcher;
+use OCP\Files\Config\IUserMountCache;
use OCP\Files\Events\Node\AbstractNodeEvent;
use OCP\Files\Events\Node\AbstractNodesEvent;
use OCP\Files\Events\Node\BeforeNodeCopiedEvent;
@@ -32,6 +33,7 @@ use OCP\Files\Events\Node\NodeWrittenEvent;
use OCP\Files\Node;
use OCP\ICacheFactory;
use OCP\IUserManager;
+use OCP\Server;
use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\GenericEvent;
use Test\TestCase;
@@ -79,15 +81,15 @@ class HookConnectorTest extends TestCase {
$this->root = new Root(
Filesystem::getMountManager(),
$this->view,
- \OC::$server->getUserManager()->get($this->userId),
- \OCP\Server::get(\OCP\Files\Config\IUserMountCache::class),
+ Server::get(IUserManager::class)->get($this->userId),
+ Server::get(IUserMountCache::class),
$this->createMock(LoggerInterface::class),
$this->createMock(IUserManager::class),
$this->createMock(IEventDispatcher::class),
$cacheFactory,
);
- $this->eventDispatcher = \OC::$server->query(IEventDispatcher::class);
- $this->logger = \OC::$server->query(LoggerInterface::class);
+ $this->eventDispatcher = Server::get(IEventDispatcher::class);
+ $this->logger = Server::get(LoggerInterface::class);
}
protected function tearDown(): void {
@@ -98,49 +100,49 @@ class HookConnectorTest extends TestCase {
public static function viewToNodeProvider(): array {
return [
- [function () {
+ [function (): void {
Filesystem::file_put_contents('test.txt', 'asd');
}, 'preWrite', '\OCP\Files::preWrite', BeforeNodeWrittenEvent::class],
- [function () {
+ [function (): void {
Filesystem::file_put_contents('test.txt', 'asd');
}, 'postWrite', '\OCP\Files::postWrite', NodeWrittenEvent::class],
- [function () {
+ [function (): void {
Filesystem::file_put_contents('test.txt', 'asd');
}, 'preCreate', '\OCP\Files::preCreate', BeforeNodeCreatedEvent::class],
- [function () {
+ [function (): void {
Filesystem::file_put_contents('test.txt', 'asd');
}, 'postCreate', '\OCP\Files::postCreate', NodeCreatedEvent::class],
- [function () {
+ [function (): void {
Filesystem::mkdir('test.txt');
}, 'preCreate', '\OCP\Files::preCreate', BeforeNodeCreatedEvent::class],
- [function () {
+ [function (): void {
Filesystem::mkdir('test.txt');
}, 'postCreate', '\OCP\Files::postCreate', NodeCreatedEvent::class],
- [function () {
+ [function (): void {
Filesystem::touch('test.txt');
}, 'preTouch', '\OCP\Files::preTouch', BeforeNodeTouchedEvent::class],
- [function () {
+ [function (): void {
Filesystem::touch('test.txt');
}, 'postTouch', '\OCP\Files::postTouch', NodeTouchedEvent::class],
- [function () {
+ [function (): void {
Filesystem::touch('test.txt');
}, 'preCreate', '\OCP\Files::preCreate', BeforeNodeCreatedEvent::class],
- [function () {
+ [function (): void {
Filesystem::touch('test.txt');
}, 'postCreate', '\OCP\Files::postCreate', NodeCreatedEvent::class],
- [function () {
+ [function (): void {
Filesystem::file_put_contents('test.txt', 'asd');
Filesystem::unlink('test.txt');
}, 'preDelete', '\OCP\Files::preDelete', BeforeNodeDeletedEvent::class],
- [function () {
+ [function (): void {
Filesystem::file_put_contents('test.txt', 'asd');
Filesystem::unlink('test.txt');
}, 'postDelete', '\OCP\Files::postDelete', NodeDeletedEvent::class],
- [function () {
+ [function (): void {
Filesystem::mkdir('test.txt');
Filesystem::rmdir('test.txt');
}, 'preDelete', '\OCP\Files::preDelete', BeforeNodeDeletedEvent::class],
- [function () {
+ [function (): void {
Filesystem::mkdir('test.txt');
Filesystem::rmdir('test.txt');
}, 'postDelete', '\OCP\Files::postDelete', NodeDeletedEvent::class],
@@ -159,7 +161,7 @@ class HookConnectorTest extends TestCase {
/** @var Node $hookNode */
$hookNode = null;
- $this->root->listen('\OC\Files', $expectedHook, function ($node) use (&$hookNode, &$hookCalled) {
+ $this->root->listen('\OC\Files', $expectedHook, function ($node) use (&$hookNode, &$hookCalled): void {
$hookCalled = true;
$hookNode = $node;
});
@@ -167,7 +169,7 @@ class HookConnectorTest extends TestCase {
$dispatcherCalled = false;
/** @var Node $dispatcherNode */
$dispatcherNode = null;
- $this->eventDispatcher->addListener($expectedLegacyEvent, function ($event) use (&$dispatcherCalled, &$dispatcherNode) {
+ $this->eventDispatcher->addListener($expectedLegacyEvent, function ($event) use (&$dispatcherCalled, &$dispatcherNode): void {
/** @var GenericEvent|APIGenericEvent $event */
$dispatcherCalled = true;
$dispatcherNode = $event->getSubject();
@@ -175,7 +177,7 @@ class HookConnectorTest extends TestCase {
$newDispatcherCalled = false;
$newDispatcherNode = null;
- $this->eventDispatcher->addListener($expectedEvent, function ($event) use ($expectedEvent, &$newDispatcherCalled, &$newDispatcherNode) {
+ $this->eventDispatcher->addListener($expectedEvent, function ($event) use ($expectedEvent, &$newDispatcherCalled, &$newDispatcherNode): void {
if ($event instanceof $expectedEvent) {
/** @var AbstractNodeEvent $event */
$newDispatcherCalled = true;
@@ -197,19 +199,19 @@ class HookConnectorTest extends TestCase {
public static function viewToNodeProviderCopyRename(): array {
return [
- [function () {
+ [function (): void {
Filesystem::file_put_contents('source', 'asd');
Filesystem::rename('source', 'target');
}, 'preRename', '\OCP\Files::preRename', BeforeNodeRenamedEvent::class],
- [function () {
+ [function (): void {
Filesystem::file_put_contents('source', 'asd');
Filesystem::rename('source', 'target');
}, 'postRename', '\OCP\Files::postRename', NodeRenamedEvent::class],
- [function () {
+ [function (): void {
Filesystem::file_put_contents('source', 'asd');
Filesystem::copy('source', 'target');
}, 'preCopy', '\OCP\Files::preCopy', BeforeNodeCopiedEvent::class],
- [function () {
+ [function (): void {
Filesystem::file_put_contents('source', 'asd');
Filesystem::copy('source', 'target');
}, 'postCopy', '\OCP\Files::postCopy', NodeCopiedEvent::class],
@@ -230,7 +232,7 @@ class HookConnectorTest extends TestCase {
/** @var Node $hookTargetNode */
$hookTargetNode = null;
- $this->root->listen('\OC\Files', $expectedHook, function ($sourceNode, $targetNode) use (&$hookCalled, &$hookSourceNode, &$hookTargetNode) {
+ $this->root->listen('\OC\Files', $expectedHook, function ($sourceNode, $targetNode) use (&$hookCalled, &$hookSourceNode, &$hookTargetNode): void {
$hookCalled = true;
$hookSourceNode = $sourceNode;
$hookTargetNode = $targetNode;
@@ -241,7 +243,7 @@ class HookConnectorTest extends TestCase {
$dispatcherSourceNode = null;
/** @var Node $dispatcherTargetNode */
$dispatcherTargetNode = null;
- $this->eventDispatcher->addListener($expectedLegacyEvent, function ($event) use (&$dispatcherSourceNode, &$dispatcherTargetNode, &$dispatcherCalled) {
+ $this->eventDispatcher->addListener($expectedLegacyEvent, function ($event) use (&$dispatcherSourceNode, &$dispatcherTargetNode, &$dispatcherCalled): void {
/** @var GenericEvent|APIGenericEvent $event */
$dispatcherCalled = true;
[$dispatcherSourceNode, $dispatcherTargetNode] = $event->getSubject();
@@ -252,7 +254,7 @@ class HookConnectorTest extends TestCase {
$newDispatcherSourceNode = null;
/** @var Node $dispatcherTargetNode */
$newDispatcherTargetNode = null;
- $this->eventDispatcher->addListener($expectedEvent, function ($event) use ($expectedEvent, &$newDispatcherSourceNode, &$newDispatcherTargetNode, &$newDispatcherCalled) {
+ $this->eventDispatcher->addListener($expectedEvent, function ($event) use ($expectedEvent, &$newDispatcherSourceNode, &$newDispatcherTargetNode, &$newDispatcherCalled): void {
if ($event instanceof $expectedEvent) {
/** @var AbstractNodesEvent$event */
$newDispatcherCalled = true;
@@ -283,7 +285,7 @@ class HookConnectorTest extends TestCase {
/** @var Node $hookNode */
$hookNode = null;
- $this->root->listen('\OC\Files', 'postDelete', function ($node) use (&$hookNode, &$hookCalled) {
+ $this->root->listen('\OC\Files', 'postDelete', function ($node) use (&$hookNode, &$hookCalled): void {
$hookCalled = true;
$hookNode = $node;
});
@@ -291,7 +293,7 @@ class HookConnectorTest extends TestCase {
$dispatcherCalled = false;
/** @var Node $dispatcherNode */
$dispatcherNode = null;
- $this->eventDispatcher->addListener('\OCP\Files::postDelete', function ($event) use (&$dispatcherCalled, &$dispatcherNode) {
+ $this->eventDispatcher->addListener('\OCP\Files::postDelete', function ($event) use (&$dispatcherCalled, &$dispatcherNode): void {
/** @var GenericEvent|APIGenericEvent $event */
$dispatcherCalled = true;
$dispatcherNode = $event->getSubject();
@@ -300,7 +302,7 @@ class HookConnectorTest extends TestCase {
$newDispatcherCalled = false;
/** @var Node $dispatcherNode */
$newDispatcherNode = null;
- $this->eventDispatcher->addListener(NodeDeletedEvent::class, function ($event) use (&$newDispatcherCalled, &$newDispatcherNode) {
+ $this->eventDispatcher->addListener(NodeDeletedEvent::class, function ($event) use (&$newDispatcherCalled, &$newDispatcherNode): void {
if ($event instanceof NodeDeletedEvent) {
/** @var AbstractNodeEvent $event */
$newDispatcherCalled = true;
diff --git a/tests/lib/Files/Node/IntegrationTest.php b/tests/lib/Files/Node/IntegrationTest.php
index c90a6115f2a..6bd956326e9 100644
--- a/tests/lib/Files/Node/IntegrationTest.php
+++ b/tests/lib/Files/Node/IntegrationTest.php
@@ -16,6 +16,7 @@ use OCP\Files\Config\IUserMountCache;
use OCP\Files\Mount\IMountManager;
use OCP\ICacheFactory;
use OCP\IUserManager;
+use OCP\Server;
use Psr\Log\LoggerInterface;
use Test\Traits\UserTrait;
@@ -47,7 +48,7 @@ class IntegrationTest extends \Test\TestCase {
protected function setUp(): void {
parent::setUp();
- $manager = \OCP\Server::get(IMountManager::class);
+ $manager = Server::get(IMountManager::class);
\OC_Hook::clear('OC_Filesystem');
@@ -64,7 +65,7 @@ class IntegrationTest extends \Test\TestCase {
$manager,
$this->view,
$user,
- \OCP\Server::get(IUserMountCache::class),
+ Server::get(IUserMountCache::class),
$this->createMock(LoggerInterface::class),
$this->createMock(IUserManager::class),
$this->createMock(IEventDispatcher::class),
diff --git a/tests/lib/Files/Node/NodeTestCase.php b/tests/lib/Files/Node/NodeTestCase.php
index a2b8a3ddffe..6da4e1e9317 100644
--- a/tests/lib/Files/Node/NodeTestCase.php
+++ b/tests/lib/Files/Node/NodeTestCase.php
@@ -9,14 +9,19 @@ namespace Test\Files\Node;
use OC\Files\FileInfo;
use OC\Files\Mount\Manager;
+use OC\Files\Node\File;
+use OC\Files\Node\Folder;
use OC\Files\Node\Root;
use OC\Files\View;
use OC\Memcache\ArrayCache;
+use OCP\Constants;
use OCP\EventDispatcher\IEventDispatcher;
+use OCP\Files\InvalidPathException;
use OCP\Files\IRootFolder;
use OCP\Files\Mount\IMountPoint;
use OCP\Files\Node;
use OCP\Files\NotFoundException;
+use OCP\Files\NotPermittedException;
use OCP\Files\Storage\IStorage;
use OCP\ICacheFactory;
use OCP\IUser;
@@ -139,7 +144,7 @@ abstract class NodeTestCase extends \Test\TestCase {
$this->view->expects($this->once())
->method('getFileInfo')
->with('/bar/foo')
- ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL]));
+ ->willReturn($this->getFileInfo(['permissions' => Constants::PERMISSION_ALL]));
$this->view->expects($this->once())
->method($this->getViewDeleteMethod())
@@ -156,7 +161,7 @@ abstract class NodeTestCase extends \Test\TestCase {
/**
* @param \OC\Files\Node\File $node
*/
- $preListener = function ($node) use (&$test, &$hooksRun) {
+ $preListener = function ($node) use (&$test, &$hooksRun): void {
$test->assertInstanceOf($this->getNodeClass(), $node);
$test->assertEquals('foo', $node->getInternalPath());
$test->assertEquals('/bar/foo', $node->getPath());
@@ -167,7 +172,7 @@ abstract class NodeTestCase extends \Test\TestCase {
/**
* @param \OC\Files\Node\File $node
*/
- $postListener = function ($node) use (&$test, &$hooksRun) {
+ $postListener = function ($node) use (&$test, &$hooksRun): void {
$test->assertInstanceOf($this->getNonExistingNodeClass(), $node);
$test->assertEquals('foo', $node->getInternalPath());
$test->assertEquals('/bar/foo', $node->getPath());
@@ -176,7 +181,7 @@ abstract class NodeTestCase extends \Test\TestCase {
$hooksRun++;
};
- $root = new \OC\Files\Node\Root(
+ $root = new Root(
$this->manager,
$this->view,
$this->user,
@@ -193,7 +198,7 @@ abstract class NodeTestCase extends \Test\TestCase {
$this->view->expects($this->any())
->method('getFileInfo')
->with('/bar/foo')
- ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL, 'fileid' => 1, 'mimetype' => 'text/plain'], 'foo'));
+ ->willReturn($this->getFileInfo(['permissions' => Constants::PERMISSION_ALL, 'fileid' => 1, 'mimetype' => 'text/plain'], 'foo'));
$this->view->expects($this->once())
->method($this->getViewDeleteMethod())
@@ -207,7 +212,7 @@ abstract class NodeTestCase extends \Test\TestCase {
public function testDeleteNotPermitted(): void {
- $this->expectException(\OCP\Files\NotPermittedException::class);
+ $this->expectException(NotPermittedException::class);
$this->root->expects($this->any())
->method('getUser')
@@ -216,7 +221,7 @@ abstract class NodeTestCase extends \Test\TestCase {
$this->view->expects($this->once())
->method('getFileInfo')
->with('/bar/foo')
- ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_READ]));
+ ->willReturn($this->getFileInfo(['permissions' => Constants::PERMISSION_READ]));
$node = $this->createTestNode($this->root, $this->view, '/bar/foo');
$node->delete();
@@ -397,7 +402,7 @@ abstract class NodeTestCase extends \Test\TestCase {
$this->view->expects($this->once())
->method('getFileInfo')
->with('/bar/foo')
- ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL]));
+ ->willReturn($this->getFileInfo(['permissions' => Constants::PERMISSION_ALL]));
$node = $this->createTestNode($this->root, $this->view, '/bar/foo');
$node->touch(100);
@@ -410,7 +415,7 @@ abstract class NodeTestCase extends \Test\TestCase {
/**
* @param \OC\Files\Node\File $node
*/
- $preListener = function ($node) use (&$test, &$hooksRun) {
+ $preListener = function ($node) use (&$test, &$hooksRun): void {
$test->assertEquals('foo', $node->getInternalPath());
$test->assertEquals('/bar/foo', $node->getPath());
$hooksRun++;
@@ -419,13 +424,13 @@ abstract class NodeTestCase extends \Test\TestCase {
/**
* @param \OC\Files\Node\File $node
*/
- $postListener = function ($node) use (&$test, &$hooksRun) {
+ $postListener = function ($node) use (&$test, &$hooksRun): void {
$test->assertEquals('foo', $node->getInternalPath());
$test->assertEquals('/bar/foo', $node->getPath());
$hooksRun++;
};
- $root = new \OC\Files\Node\Root(
+ $root = new Root(
$this->manager,
$this->view,
$this->user,
@@ -446,7 +451,7 @@ abstract class NodeTestCase extends \Test\TestCase {
$this->view->expects($this->any())
->method('getFileInfo')
->with('/bar/foo')
- ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL], 'foo'));
+ ->willReturn($this->getFileInfo(['permissions' => Constants::PERMISSION_ALL], 'foo'));
$node = $this->createTestNode($root, $this->view, '/bar/foo');
$node->touch(100);
@@ -455,7 +460,7 @@ abstract class NodeTestCase extends \Test\TestCase {
public function testTouchNotPermitted(): void {
- $this->expectException(\OCP\Files\NotPermittedException::class);
+ $this->expectException(NotPermittedException::class);
$this->root->expects($this->any())
->method('getUser')
@@ -464,7 +469,7 @@ abstract class NodeTestCase extends \Test\TestCase {
$this->view->expects($this->any())
->method('getFileInfo')
->with('/bar/foo')
- ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_READ]));
+ ->willReturn($this->getFileInfo(['permissions' => Constants::PERMISSION_READ]));
$node = $this->createTestNode($this->root, $this->view, '/bar/foo');
$node->touch(100);
@@ -472,7 +477,7 @@ abstract class NodeTestCase extends \Test\TestCase {
public function testInvalidPath(): void {
- $this->expectException(\OCP\Files\InvalidPathException::class);
+ $this->expectException(InvalidPathException::class);
$node = $this->createTestNode($this->root, $this->view, '/../foo');
$node->getFileInfo();
@@ -486,10 +491,10 @@ abstract class NodeTestCase extends \Test\TestCase {
$this->view->expects($this->any())
->method('getFileInfo')
- ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL, 'fileid' => 3]));
+ ->willReturn($this->getFileInfo(['permissions' => Constants::PERMISSION_ALL, 'fileid' => 3]));
$node = $this->createTestNode($this->root, $this->view, '/bar/foo');
- $parentNode = new \OC\Files\Node\Folder($this->root, $this->view, '/bar');
+ $parentNode = new Folder($this->root, $this->view, '/bar');
$newNode = $this->createTestNode($this->root, $this->view, '/bar/asd');
$this->root->method('get')
@@ -505,7 +510,7 @@ abstract class NodeTestCase extends \Test\TestCase {
public function testCopyNotPermitted(): void {
- $this->expectException(\OCP\Files\NotPermittedException::class);
+ $this->expectException(NotPermittedException::class);
/**
* @var \OC\Files\Storage\Storage | \PHPUnit\Framework\MockObject\MockObject $storage
@@ -520,10 +525,10 @@ abstract class NodeTestCase extends \Test\TestCase {
$this->view->expects($this->any())
->method('getFileInfo')
- ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_READ, 'fileid' => 3]));
+ ->willReturn($this->getFileInfo(['permissions' => Constants::PERMISSION_READ, 'fileid' => 3]));
$node = $this->createTestNode($this->root, $this->view, '/bar/foo');
- $parentNode = new \OC\Files\Node\Folder($this->root, $this->view, '/bar');
+ $parentNode = new Folder($this->root, $this->view, '/bar');
$this->root->expects($this->once())
->method('get')
@@ -536,7 +541,7 @@ abstract class NodeTestCase extends \Test\TestCase {
public function testCopyNoParent(): void {
- $this->expectException(\OCP\Files\NotFoundException::class);
+ $this->expectException(NotFoundException::class);
$this->view->expects($this->never())
->method('copy');
@@ -546,20 +551,20 @@ abstract class NodeTestCase extends \Test\TestCase {
$this->root->expects($this->once())
->method('get')
->with('/bar/asd')
- ->will($this->throwException(new NotFoundException()));
+ ->willThrowException(new NotFoundException());
$node->copy('/bar/asd/foo');
}
public function testCopyParentIsFile(): void {
- $this->expectException(\OCP\Files\NotPermittedException::class);
+ $this->expectException(NotPermittedException::class);
$this->view->expects($this->never())
->method('copy');
$node = $this->createTestNode($this->root, $this->view, '/bar/foo');
- $parentNode = new \OC\Files\Node\File($this->root, $this->view, '/bar');
+ $parentNode = new File($this->root, $this->view, '/bar');
$this->root->expects($this->once())
->method('get')
@@ -578,10 +583,10 @@ abstract class NodeTestCase extends \Test\TestCase {
$this->view->expects($this->any())
->method('getFileInfo')
- ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL, 'fileid' => 1]));
+ ->willReturn($this->getFileInfo(['permissions' => Constants::PERMISSION_ALL, 'fileid' => 1]));
$node = $this->createTestNode($this->root, $this->view, '/bar/foo');
- $parentNode = new \OC\Files\Node\Folder($this->root, $this->view, '/bar');
+ $parentNode = new Folder($this->root, $this->view, '/bar');
$this->root->expects($this->any())
->method('get')
@@ -621,13 +626,13 @@ abstract class NodeTestCase extends \Test\TestCase {
$this->view->expects($this->any())
->method('getFileInfo')
- ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL, 'fileid' => 1]));
+ ->willReturn($this->getFileInfo(['permissions' => Constants::PERMISSION_ALL, 'fileid' => 1]));
/**
* @var \OC\Files\Node\File|\PHPUnit\Framework\MockObject\MockObject $node
*/
$node = $this->createTestNode($root, $this->view, '/bar/foo');
- $parentNode = new \OC\Files\Node\Folder($root, $this->view, '/bar');
+ $parentNode = new Folder($root, $this->view, '/bar');
$targetTestNode = $this->createTestNode($root, $this->view, '/bar/asd');
$root->expects($this->any())
@@ -636,7 +641,7 @@ abstract class NodeTestCase extends \Test\TestCase {
$hooksRun = 0;
- $preListener = function (Node $sourceNode, Node $targetNode) use (&$hooksRun, $node) {
+ $preListener = function (Node $sourceNode, Node $targetNode) use (&$hooksRun, $node): void {
$this->assertSame($node, $sourceNode);
$this->assertInstanceOf($this->getNodeClass(), $sourceNode);
$this->assertInstanceOf($this->getNonExistingNodeClass(), $targetNode);
@@ -644,7 +649,7 @@ abstract class NodeTestCase extends \Test\TestCase {
$hooksRun++;
};
- $postListener = function (Node $sourceNode, Node $targetNode) use (&$hooksRun, $node, $targetTestNode) {
+ $postListener = function (Node $sourceNode, Node $targetNode) use (&$hooksRun, $node, $targetTestNode): void {
$this->assertSame($node, $sourceNode);
$this->assertNotSame($node, $targetNode);
$this->assertSame($targetTestNode, $targetNode);
@@ -653,13 +658,13 @@ abstract class NodeTestCase extends \Test\TestCase {
$hooksRun++;
};
- $preWriteListener = function (Node $targetNode) use (&$hooksRun) {
+ $preWriteListener = function (Node $targetNode) use (&$hooksRun): void {
$this->assertInstanceOf($this->getNonExistingNodeClass(), $targetNode);
$this->assertEquals('/bar/asd', $targetNode->getPath());
$hooksRun++;
};
- $postWriteListener = function (Node $targetNode) use (&$hooksRun, $targetTestNode) {
+ $postWriteListener = function (Node $targetNode) use (&$hooksRun, $targetTestNode): void {
$this->assertSame($targetTestNode, $targetNode);
$hooksRun++;
};
@@ -676,17 +681,17 @@ abstract class NodeTestCase extends \Test\TestCase {
public function testMoveNotPermitted(): void {
- $this->expectException(\OCP\Files\NotPermittedException::class);
+ $this->expectException(NotPermittedException::class);
$this->view->expects($this->any())
->method('getFileInfo')
- ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_READ]));
+ ->willReturn($this->getFileInfo(['permissions' => Constants::PERMISSION_READ]));
$this->view->expects($this->never())
->method('rename');
$node = $this->createTestNode($this->root, $this->view, '/bar/foo');
- $parentNode = new \OC\Files\Node\Folder($this->root, $this->view, '/bar');
+ $parentNode = new Folder($this->root, $this->view, '/bar');
$this->root->expects($this->once())
->method('get')
@@ -698,7 +703,7 @@ abstract class NodeTestCase extends \Test\TestCase {
public function testMoveNoParent(): void {
- $this->expectException(\OCP\Files\NotFoundException::class);
+ $this->expectException(NotFoundException::class);
/**
* @var \OC\Files\Storage\Storage | \PHPUnit\Framework\MockObject\MockObject $storage
@@ -713,20 +718,20 @@ abstract class NodeTestCase extends \Test\TestCase {
$this->root->expects($this->once())
->method('get')
->with('/bar')
- ->will($this->throwException(new NotFoundException()));
+ ->willThrowException(new NotFoundException());
$node->move('/bar/asd');
}
public function testMoveParentIsFile(): void {
- $this->expectException(\OCP\Files\NotPermittedException::class);
+ $this->expectException(NotPermittedException::class);
$this->view->expects($this->never())
->method('rename');
$node = $this->createTestNode($this->root, $this->view, '/bar/foo');
- $parentNode = new \OC\Files\Node\File($this->root, $this->view, '/bar');
+ $parentNode = new File($this->root, $this->view, '/bar');
$this->root->expects($this->once())
->method('get')
@@ -738,7 +743,7 @@ abstract class NodeTestCase extends \Test\TestCase {
public function testMoveFailed(): void {
- $this->expectException(\OCP\Files\NotPermittedException::class);
+ $this->expectException(NotPermittedException::class);
$this->view->expects($this->any())
->method('rename')
@@ -747,10 +752,10 @@ abstract class NodeTestCase extends \Test\TestCase {
$this->view->expects($this->any())
->method('getFileInfo')
- ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL, 'fileid' => 1]));
+ ->willReturn($this->getFileInfo(['permissions' => Constants::PERMISSION_ALL, 'fileid' => 1]));
$node = $this->createTestNode($this->root, $this->view, '/bar/foo');
- $parentNode = new \OC\Files\Node\Folder($this->root, $this->view, '/bar');
+ $parentNode = new Folder($this->root, $this->view, '/bar');
$this->root->expects($this->any())
->method('get')
@@ -761,7 +766,7 @@ abstract class NodeTestCase extends \Test\TestCase {
public function testCopyFailed(): void {
- $this->expectException(\OCP\Files\NotPermittedException::class);
+ $this->expectException(NotPermittedException::class);
$this->view->expects($this->any())
->method('copy')
@@ -770,10 +775,10 @@ abstract class NodeTestCase extends \Test\TestCase {
$this->view->expects($this->any())
->method('getFileInfo')
- ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL, 'fileid' => 1]));
+ ->willReturn($this->getFileInfo(['permissions' => Constants::PERMISSION_ALL, 'fileid' => 1]));
$node = $this->createTestNode($this->root, $this->view, '/bar/foo');
- $parentNode = new \OC\Files\Node\Folder($this->root, $this->view, '/bar');
+ $parentNode = new Folder($this->root, $this->view, '/bar');
$this->root->expects($this->any())
->method('get')
diff --git a/tests/lib/Files/Node/RootTest.php b/tests/lib/Files/Node/RootTest.php
index f2ef1a0e3ee..979ed1c6dcb 100644
--- a/tests/lib/Files/Node/RootTest.php
+++ b/tests/lib/Files/Node/RootTest.php
@@ -10,10 +10,14 @@ namespace Test\Files\Node;
use OC\Files\FileInfo;
use OC\Files\Mount\Manager;
use OC\Files\Node\Folder;
+use OC\Files\Node\Root;
use OC\Files\View;
use OC\Memcache\ArrayCache;
+use OC\User\NoUserException;
use OCP\Cache\CappedMemoryCache;
use OCP\EventDispatcher\IEventDispatcher;
+use OCP\Files\NotFoundException;
+use OCP\Files\NotPermittedException;
use OCP\ICacheFactory;
use OCP\IUser;
use OCP\IUserManager;
@@ -83,7 +87,7 @@ class RootTest extends \Test\TestCase {
->disableOriginalConstructor()
->getMock();
$view = $this->getRootViewMock();
- $root = new \OC\Files\Node\Root(
+ $root = new Root(
$this->manager,
$view,
$this->user,
@@ -107,7 +111,7 @@ class RootTest extends \Test\TestCase {
public function testGetNotFound(): void {
- $this->expectException(\OCP\Files\NotFoundException::class);
+ $this->expectException(NotFoundException::class);
/**
* @var \OC\Files\Storage\Storage $storage
@@ -116,7 +120,7 @@ class RootTest extends \Test\TestCase {
->disableOriginalConstructor()
->getMock();
$view = $this->getRootViewMock();
- $root = new \OC\Files\Node\Root(
+ $root = new Root(
$this->manager,
$view,
$this->user,
@@ -138,10 +142,10 @@ class RootTest extends \Test\TestCase {
public function testGetInvalidPath(): void {
- $this->expectException(\OCP\Files\NotPermittedException::class);
+ $this->expectException(NotPermittedException::class);
$view = $this->getRootViewMock();
- $root = new \OC\Files\Node\Root(
+ $root = new Root(
$this->manager,
$view,
$this->user,
@@ -157,10 +161,10 @@ class RootTest extends \Test\TestCase {
public function testGetNoStorages(): void {
- $this->expectException(\OCP\Files\NotFoundException::class);
+ $this->expectException(NotFoundException::class);
$view = $this->getRootViewMock();
- $root = new \OC\Files\Node\Root(
+ $root = new Root(
$this->manager,
$view,
$this->user,
@@ -175,7 +179,7 @@ class RootTest extends \Test\TestCase {
}
public function testGetUserFolder(): void {
- $root = new \OC\Files\Node\Root(
+ $root = new Root(
$this->manager,
$this->getRootViewMock(),
$this->user,
@@ -214,10 +218,10 @@ class RootTest extends \Test\TestCase {
public function testGetUserFolderWithNoUserObj(): void {
- $this->expectException(\OC\User\NoUserException::class);
+ $this->expectException(NoUserException::class);
$this->expectExceptionMessage('Backends provided no user object');
- $root = new \OC\Files\Node\Root(
+ $root = new Root(
$this->createMock(Manager::class),
$this->getRootViewMock(),
null,