summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2015-12-16 15:03:50 +0100
committerMorris Jobke <hey@morrisjobke.de>2015-12-16 15:03:50 +0100
commit89233cab8385740c11e566d7507f2e06371bef32 (patch)
treed8388dc0f257645134e0d6e0b5e013a4a8b2e4ff
parent66c0f4eb5967de6d945a3f3a6266a4cef69e0342 (diff)
downloadnextcloud-server-89233cab8385740c11e566d7507f2e06371bef32.tar.gz
nextcloud-server-89233cab8385740c11e566d7507f2e06371bef32.zip
add unit test for #21230
-rw-r--r--apps/dav/tests/unit/connector/sabre/objecttree.php41
1 files changed, 41 insertions, 0 deletions
diff --git a/apps/dav/tests/unit/connector/sabre/objecttree.php b/apps/dav/tests/unit/connector/sabre/objecttree.php
index 1cea4ff0b69..6164b96c986 100644
--- a/apps/dav/tests/unit/connector/sabre/objecttree.php
+++ b/apps/dav/tests/unit/connector/sabre/objecttree.php
@@ -294,4 +294,45 @@ class ObjectTree extends \Test\TestCase {
$this->assertInstanceOf('\Sabre\DAV\INode', $tree->getNodeForPath($path));
}
+
+ /**
+ * @expectedException \Sabre\DAV\Exception\Forbidden
+ * @expectedExceptionMessage Could not copy directory nameOfSourceNode, target exists
+ */
+ public function testFailingMove() {
+ $source = 'a/b';
+ $destination = 'b/b';
+ $updatables = array('a' => true, 'a/b' => true, 'b' => true, 'b/b' => false);
+ $deletables = array('a/b' => true);
+
+ $view = new TestDoubleFileView($updatables, $deletables);
+
+ $info = new FileInfo('', null, null, array(), null);
+
+ $rootDir = new \OCA\DAV\Connector\Sabre\Directory($view, $info);
+ $objectTree = $this->getMock('\OCA\DAV\Connector\Sabre\ObjectTree',
+ array('nodeExists', 'getNodeForPath'),
+ array($rootDir, $view));
+
+ $sourceNode = $this->getMockBuilder('\Sabre\DAV\ICollection')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $sourceNode->expects($this->once())
+ ->method('getName')
+ ->will($this->returnValue('nameOfSourceNode'));
+
+ $objectTree->expects($this->once())
+ ->method('nodeExists')
+ ->with($this->identicalTo($destination))
+ ->will($this->returnValue(true));
+ $objectTree->expects($this->once())
+ ->method('getNodeForPath')
+ ->with($this->identicalTo($source))
+ ->will($this->returnValue($sourceNode));
+
+ /** @var $objectTree \OCA\DAV\Connector\Sabre\ObjectTree */
+ $mountManager = \OC\Files\Filesystem::getMountManager();
+ $objectTree->init($rootDir, $view, $mountManager);
+ $objectTree->move($source, $destination);
+ }
}