summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2016-11-14 18:29:11 +0100
committerRobin Appelman <robin@icewind.nl>2017-01-12 13:52:59 +0100
commite667b28298add5b6ecc6a3956bfb93cb4a047097 (patch)
tree88c6097f4d945a41d58226db2ebf5cebfe3503f5 /tests
parenteb5ea0e260bf52dfc5752be76f6271d1c6f323c7 (diff)
downloadnextcloud-server-e667b28298add5b6ecc6a3956bfb93cb4a047097.tar.gz
nextcloud-server-e667b28298add5b6ecc6a3956bfb93cb4a047097.zip
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 <pvince81@owncloud.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Files/Node/FileTest.php3
-rw-r--r--tests/lib/Files/Node/NodeTest.php47
2 files changed, 46 insertions, 4 deletions
diff --git a/tests/lib/Files/Node/FileTest.php b/tests/lib/Files/Node/FileTest.php
index 87402cd5f52..a17cc1d1a3a 100644
--- a/tests/lib/Files/Node/FileTest.php
+++ b/tests/lib/Files/Node/FileTest.php
@@ -16,9 +16,6 @@ namespace Test\Files\Node;
* @package Test\Files\Node
*/
class FileTest extends NodeTest {
-
- public $viewDeleteMethod = 'unlink';
-
protected function createTestNode($root, $view, $path) {
return new \OC\Files\Node\File($root, $view, $path);
}
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');
+ }
}