[Pkg-owncloud-commits] [owncloud] 382/457: tests for getNodeForPath with invalid path

David Prévot taffit at moszumanska.debian.org
Sun Jun 28 20:06:50 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch stable8
in repository owncloud.

commit 5a5639ab763662d8105bc61c5f124fcc99a7a813
Author: Robin Appelman <icewind at owncloud.com>
Date:   Thu Jun 11 17:25:06 2015 +0200

    tests for getNodeForPath with invalid path
---
 tests/lib/connector/sabre/objecttree.php | 62 ++++++++++++++++++++++++++++----
 1 file changed, 56 insertions(+), 6 deletions(-)

diff --git a/tests/lib/connector/sabre/objecttree.php b/tests/lib/connector/sabre/objecttree.php
index 53e53f1..b9f8591 100644
--- a/tests/lib/connector/sabre/objecttree.php
+++ b/tests/lib/connector/sabre/objecttree.php
@@ -11,6 +11,7 @@ namespace Test\OC\Connector\Sabre;
 
 use OC\Files\FileInfo;
 use OC\Connector\Sabre\Directory;
+use OC\Files\Storage\Temporary;
 
 class TestDoubleFileView extends \OC\Files\View {
 
@@ -36,7 +37,7 @@ class TestDoubleFileView extends \OC\Files\View {
 		return $this->canRename;
 	}
 
-	public function getRelativePath($path){
+	public function getRelativePath($path) {
 		return $path;
 	}
 }
@@ -122,11 +123,11 @@ class ObjectTree extends \Test\TestCase {
 	 * @dataProvider nodeForPathProvider
 	 */
 	public function testGetNodeForPath(
-			$inputFileName,
-			$fileInfoQueryPath,
-			$outputFileName,
-			$type,
-			$enableChunkingHeader
+		$inputFileName,
+		$fileInfoQueryPath,
+		$outputFileName,
+		$type,
+		$enableChunkingHeader
 	) {
 
 		if ($enableChunkingHeader) {
@@ -237,4 +238,53 @@ class ObjectTree extends \Test\TestCase {
 		);
 	}
 
+	/**
+	 * @expectedException \OCP\Files\InvalidPathException
+	 */
+	public function testGetNodeForPathInvalidPath() {
+		$path = '/foo\bar';
+
+
+		$storage = new Temporary([]);
+
+		$view = $this->getMock('\OC\Files\View', ['resolvePath']);
+		$view->expects($this->once())
+			->method('resolvePath')
+			->will($this->returnCallback(function($path) use ($storage){
+			return [$storage, ltrim($path, '/')];
+		}));
+
+		$rootNode = $this->getMockBuilder('\OC\Connector\Sabre\Directory')
+			->disableOriginalConstructor()
+			->getMock();
+		$mountManager = $this->getMock('\OC\Files\Mount\Manager');
+
+		$tree = new \OC\Connector\Sabre\ObjectTree();
+		$tree->init($rootNode, $view, $mountManager);
+
+		$tree->getNodeForPath($path);
+	}
+	public function testGetNodeForPathRoot() {
+		$path = '/';
+
+
+		$storage = new Temporary([]);
+
+		$view = $this->getMock('\OC\Files\View', ['resolvePath']);
+		$view->expects($this->any())
+			->method('resolvePath')
+			->will($this->returnCallback(function ($path) use ($storage) {
+				return [$storage, ltrim($path, '/')];
+			}));
+
+		$rootNode = $this->getMockBuilder('\OC\Connector\Sabre\Directory')
+			->disableOriginalConstructor()
+			->getMock();
+		$mountManager = $this->getMock('\OC\Files\Mount\Manager');
+
+		$tree = new \OC\Connector\Sabre\ObjectTree();
+		$tree->init($rootNode, $view, $mountManager);
+
+		$tree->getNodeForPath($path);
+	}
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list