aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/Files/Node/NodeTestCase.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/Files/Node/NodeTestCase.php')
-rw-r--r--tests/lib/Files/Node/NodeTestCase.php95
1 files changed, 50 insertions, 45 deletions
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')