From e667b28298add5b6ecc6a3956bfb93cb4a047097 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Mon, 14 Nov 2016 18:29:11 +0100 Subject: Fix files node API failed rename/copy Whenever a rename or copy operation failed on the view, we must throw an exception instead of just ignoring. Signed-off-by: Vincent Petry --- tests/lib/Files/Node/NodeTest.php | 47 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) (limited to 'tests/lib/Files/Node/NodeTest.php') diff --git a/tests/lib/Files/Node/NodeTest.php b/tests/lib/Files/Node/NodeTest.php index ce7250dc064..03f9118d9e4 100644 --- a/tests/lib/Files/Node/NodeTest.php +++ b/tests/lib/Files/Node/NodeTest.php @@ -614,7 +614,6 @@ abstract class NodeTest extends \Test\TestCase { ->method('rename'); $node = $this->createTestNode($this->root, $this->view, '/bar/foo'); - $parentNode = new \OC\Files\Node\Folder($this->root, $this->view, '/bar'); $this->root->expects($this->once()) ->method('get') @@ -641,4 +640,50 @@ abstract class NodeTest extends \Test\TestCase { $node->move('/bar/asd'); } + + /** + * @expectedException \OCP\Files\NotPermittedException + */ + public function testMoveFailed() { + $this->view->expects($this->any()) + ->method('rename') + ->with('/bar/foo', '/bar/asd') + ->will($this->returnValue(false)); + + $this->view->expects($this->any()) + ->method('getFileInfo') + ->will($this->returnValue($this->getFileInfo(['permissions' => \OCP\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'); + + $this->root->expects($this->any()) + ->method('get') + ->will($this->returnValueMap([['/bar', $parentNode], ['/bar/asd', $node]])); + + $node->move('/bar/asd'); + } + + /** + * @expectedException \OCP\Files\NotPermittedException + */ + public function testCopyFailed() { + $this->view->expects($this->any()) + ->method('copy') + ->with('/bar/foo', '/bar/asd') + ->will($this->returnValue(false)); + + $this->view->expects($this->any()) + ->method('getFileInfo') + ->will($this->returnValue($this->getFileInfo(['permissions' => \OCP\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'); + + $this->root->expects($this->any()) + ->method('get') + ->will($this->returnValueMap([['/bar', $parentNode], ['/bar/asd', $node]])); + + $node->copy('/bar/asd'); + } } -- cgit v1.2.3