From 89233cab8385740c11e566d7507f2e06371bef32 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Wed, 16 Dec 2015 15:03:50 +0100 Subject: [PATCH] add unit test for #21230 --- .../tests/unit/connector/sabre/objecttree.php | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) 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); + } } -- 2.39.5