[Pkg-owncloud-commits] [php-sabredav] 183/275: Removed ObjectTree and Tree\FileSystem

David Prévot taffit at moszumanska.debian.org
Thu Sep 25 14:56:06 UTC 2014


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

taffit pushed a commit to branch master
in repository php-sabredav.

commit f40233ae8187152e1c6c95934f354730092462ed
Author: Evert Pot <evert at rooftopsolutions.nl>
Date:   Sun Aug 24 21:07:06 2014 -0400

    Removed ObjectTree and Tree\FileSystem
    
    The distinction between ObjectTree and Tree\FileSystem was an extremely
    rarely used extension point.
    
    With the advent of IMoveTarget, Tree\FileSystem also becomes unneeded.
---
 lib/DAV/ObjectTree.php                             | 213 ---------------------
 lib/DAV/Server.php                                 |  10 +-
 lib/DAV/Tree.php                                   | 127 ++++++++++--
 lib/DAV/Tree/Filesystem.php                        | 133 -------------
 tests/Sabre/CalDAV/PluginTest.php                  |   3 +-
 tests/Sabre/DAV/Auth/Backend/AbstractBasicTest.php |   4 +-
 tests/Sabre/DAV/Issue33Test.php                    |   4 +-
 tests/Sabre/DAV/Locks/PluginTest.php               |   2 +-
 tests/Sabre/DAV/ObjectTreeTest.php                 |   2 +-
 tests/Sabre/DAV/ServerCopyMoveTest.php             |   2 +-
 tests/Sabre/DAV/ServerPropsTest.php                |   6 +-
 tests/Sabre/DAV/Tree/FilesystemTest.php            |  88 ---------
 tests/Sabre/DAVACL/PrincipalPropertySearchTest.php |   2 +-
 .../DAVACL/PrincipalSearchPropertySetTest.php      |   2 +-
 tests/Sabre/DAVACL/Property/PrincipalTest.php      |   8 +-
 15 files changed, 138 insertions(+), 468 deletions(-)

diff --git a/lib/DAV/ObjectTree.php b/lib/DAV/ObjectTree.php
deleted file mode 100644
index 8c2bbcc..0000000
--- a/lib/DAV/ObjectTree.php
+++ /dev/null
@@ -1,213 +0,0 @@
-<?php
-
-namespace Sabre\DAV;
-
-use Sabre\HTTP\URLUtil;
-
-/**
- * ObjectTree class
- *
- * This implementation of the Tree class makes use of the INode, IFile and ICollection API's
- *
- * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/).
- * @author Evert Pot (http://evertpot.com/)
- * @license http://sabre.io/license/ Modified BSD License
- */
-class ObjectTree extends Tree {
-
-    /**
-     * The root node
-     *
-     * @var ICollection
-     */
-    protected $rootNode;
-
-    /**
-     * This is the node cache. Accessed nodes are stored here
-     *
-     * @var array
-     */
-    protected $cache = array();
-
-    /**
-     * Creates the object
-     *
-     * This method expects the rootObject to be passed as a parameter
-     *
-     * @param ICollection $rootNode
-     */
-    public function __construct(ICollection $rootNode) {
-
-        $this->rootNode = $rootNode;
-
-    }
-
-    /**
-     * Returns the INode object for the requested path
-     *
-     * @param string $path
-     * @return INode
-     */
-    public function getNodeForPath($path) {
-
-        $path = trim($path,'/');
-        if (isset($this->cache[$path])) return $this->cache[$path];
-
-        // Is it the root node?
-        if (!strlen($path)) {
-            return $this->rootNode;
-        }
-
-        // Attempting to fetch its parent
-        list($parentName, $baseName) = URLUtil::splitPath($path);
-
-        // If there was no parent, we must simply ask it from the root node.
-        if ($parentName==="") {
-            $node = $this->rootNode->getChild($baseName);
-        } else {
-            // Otherwise, we recursively grab the parent and ask him/her.
-            $parent = $this->getNodeForPath($parentName);
-
-            if (!($parent instanceof ICollection))
-                throw new Exception\NotFound('Could not find node at path: ' . $path);
-
-            $node = $parent->getChild($baseName);
-
-        }
-
-        $this->cache[$path] = $node;
-        return $node;
-
-    }
-
-    /**
-     * This function allows you to check if a node exists.
-     *
-     * @param string $path
-     * @return bool
-     */
-    public function nodeExists($path) {
-
-        try {
-
-            // The root always exists
-            if ($path==='') return true;
-
-            list($parent, $base) = URLUtil::splitPath($path);
-
-            $parentNode = $this->getNodeForPath($parent);
-            if (!$parentNode instanceof ICollection) return false;
-            return $parentNode->childExists($base);
-
-        } catch (Exception\NotFound $e) {
-
-            return false;
-
-        }
-
-    }
-
-    /**
-     * Returns a list of childnodes for a given path.
-     *
-     * @param string $path
-     * @return array
-     */
-    public function getChildren($path) {
-
-        $node = $this->getNodeForPath($path);
-        $children = $node->getChildren();
-        foreach($children as $child) {
-
-            $this->cache[trim($path,'/') . '/' . $child->getName()] = $child;
-
-        }
-        return $children;
-
-    }
-
-    /**
-     * This method is called with every tree update
-     *
-     * Examples of tree updates are:
-     *   * node deletions
-     *   * node creations
-     *   * copy
-     *   * move
-     *   * renaming nodes
-     *
-     * If Tree classes implement a form of caching, this will allow
-     * them to make sure caches will be expired.
-     *
-     * If a path is passed, it is assumed that the entire subtree is dirty
-     *
-     * @param string $path
-     * @return void
-     */
-    public function markDirty($path) {
-
-        // We don't care enough about sub-paths
-        // flushing the entire cache
-        $path = trim($path,'/');
-        foreach($this->cache as $nodePath=>$node) {
-            if ($nodePath == $path || strpos($nodePath,$path.'/')===0)
-                unset($this->cache[$nodePath]);
-
-        }
-
-    }
-
-    /**
-     * This method tells the tree system to pre-fetch and cache a list of
-     * children of a single parent.
-     *
-     * There are a bunch of operations in the WebDAV stack that request many
-     * children (based on uris), and sometimes fetching many at once can
-     * optimize this.
-     *
-     * This method returns an array with the found nodes. It's keys are the
-     * original paths. The result may be out of order.
-     *
-     * @param array $paths List of nodes that must be fetched.
-     * @return array
-     */
-    public function getMultipleNodes($paths) {
-
-        // Finding common parents
-        $parents = [];
-        foreach($paths as $path) {
-            list($parent, $node) = URLUtil::splitPath($path);
-            if (!isset($parents[$parent])) {
-                $parents[$parent] = [$node];
-            } else {
-                $parents[$parent][] = $node;
-            }
-        }
-
-        $result = [];
-
-        foreach($parents as $parent=>$children) {
-
-            $parentNode = $this->getNodeForPath($parent);
-            if ($parentNode instanceof IMultiGet) {
-                foreach($parentNode->getMultipleChildren($children) as $childNode) {
-                    $fullPath = $parent . '/' . $childNode->getName();
-                    $result[$fullPath] = $childNode;
-                    $this->cache[$fullPath] = $childNode;
-                }
-            } else {
-                foreach($children as $child) {
-                    $fullPath = $parent . '/' . $child;
-                    $result[$fullPath] = $this->getNodeForPath($fullPath);
-                }
-            }
-
-        }
-
-        return $result;
-
-    }
-
-
-}
-
diff --git a/lib/DAV/Server.php b/lib/DAV/Server.php
index c443005..bc61768 100644
--- a/lib/DAV/Server.php
+++ b/lib/DAV/Server.php
@@ -180,10 +180,10 @@ class Server extends EventEmitter {
      *
      * If a Sabre\DAV\Tree object is passed as an argument, it will
      * use it as the directory tree. If a Sabre\DAV\INode is passed, it
-     * will create a Sabre\DAV\ObjectTree and use the node as the root.
+     * will create a Sabre\DAV\Tree and use the node as the root.
      *
      * If nothing is passed, a Sabre\DAV\SimpleCollection is created in
-     * a Sabre\DAV\ObjectTree.
+     * a Sabre\DAV\Tree.
      *
      * If an array is passed, we automatically create a root node, and use
      * the nodes in the array as top-level children.
@@ -195,7 +195,7 @@ class Server extends EventEmitter {
         if ($treeOrNode instanceof Tree) {
             $this->tree = $treeOrNode;
         } elseif ($treeOrNode instanceof INode) {
-            $this->tree = new ObjectTree($treeOrNode);
+            $this->tree = new Tree($treeOrNode);
         } elseif (is_array($treeOrNode)) {
 
             // If it's an array, a list of nodes was passed, and we need to
@@ -207,11 +207,11 @@ class Server extends EventEmitter {
             }
 
             $root = new SimpleCollection('root', $treeOrNode);
-            $this->tree = new ObjectTree($root);
+            $this->tree = new Tree($root);
 
         } elseif (is_null($treeOrNode)) {
             $root = new SimpleCollection('root');
-            $this->tree = new ObjectTree($root);
+            $this->tree = new Tree($root);
         } else {
             throw new Exception('Invalid argument passed to constructor. Argument must either be an instance of Sabre\\DAV\\Tree, Sabre\\DAV\\INode, an array or null');
         }
diff --git a/lib/DAV/Tree.php b/lib/DAV/Tree.php
index c1bd24c..d7d72c5 100644
--- a/lib/DAV/Tree.php
+++ b/lib/DAV/Tree.php
@@ -5,23 +5,81 @@ namespace Sabre\DAV;
 use Sabre\HTTP\URLUtil;
 
 /**
- * Abstract tree object
+ * The tree object is responsible for basic tree operations.
+ *
+ * It allows for fetching nodes by path, facilitates deleting, copying and
+ * moving.
  *
  * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/).
  * @author Evert Pot (http://evertpot.com/)
  * @license http://sabre.io/license/ Modified BSD License
  */
-abstract class Tree {
+class Tree {
+
+    /**
+     * The root node
+     *
+     * @var ICollection
+     */
+    protected $rootNode;
+
+    /**
+     * This is the node cache. Accessed nodes are stored here
+     *
+     * @var array
+     */
+    protected $cache = array();
 
     /**
-     * This function must return an INode object for a path
-     * If a Path doesn't exist, thrown a Exception_NotFound
+     * Creates the object
+     *
+     * This method expects the rootObject to be passed as a parameter
+     *
+     * @param ICollection $rootNode
+     */
+    function __construct(ICollection $rootNode) {
+
+        $this->rootNode = $rootNode;
+
+    }
+
+    /**
+     * Returns the INode object for the requested path
      *
      * @param string $path
-     * @throws Exception\NotFound
      * @return INode
      */
-    abstract function getNodeForPath($path);
+    function getNodeForPath($path) {
+
+        $path = trim($path,'/');
+        if (isset($this->cache[$path])) return $this->cache[$path];
+
+        // Is it the root node?
+        if (!strlen($path)) {
+            return $this->rootNode;
+        }
+
+        // Attempting to fetch its parent
+        list($parentName, $baseName) = URLUtil::splitPath($path);
+
+        // If there was no parent, we must simply ask it from the root node.
+        if ($parentName==="") {
+            $node = $this->rootNode->getChild($baseName);
+        } else {
+            // Otherwise, we recursively grab the parent and ask him/her.
+            $parent = $this->getNodeForPath($parentName);
+
+            if (!($parent instanceof ICollection))
+                throw new Exception\NotFound('Could not find node at path: ' . $path);
+
+            $node = $parent->getChild($baseName);
+
+        }
+
+        $this->cache[$path] = $node;
+        return $node;
+
+    }
 
     /**
      * This function allows you to check if a node exists.
@@ -36,8 +94,14 @@ abstract class Tree {
 
         try {
 
-            $this->getNodeForPath($path);
-            return true;
+            // The root always exists
+            if ($path==='') return true;
+
+            list($parent, $base) = URLUtil::splitPath($path);
+
+            $parentNode = $this->getNodeForPath($parent);
+            if (!$parentNode instanceof ICollection) return false;
+            return $parentNode->childExists($base);
 
         } catch (Exception\NotFound $e) {
 
@@ -127,7 +191,13 @@ abstract class Tree {
     function getChildren($path) {
 
         $node = $this->getNodeForPath($path);
-        return $node->getChildren();
+        $children = $node->getChildren();
+        foreach($children as $child) {
+
+            $this->cache[trim($path,'/') . '/' . $child->getName()] = $child;
+
+        }
+        return $children;
 
     }
 
@@ -151,6 +221,14 @@ abstract class Tree {
      */
     function markDirty($path) {
 
+        // We don't care enough about sub-paths
+        // flushing the entire cache
+        $path = trim($path,'/');
+        foreach($this->cache as $nodePath=>$node) {
+            if ($nodePath == $path || strpos($nodePath,$path.'/')===0)
+                unset($this->cache[$nodePath]);
+
+        }
 
     }
 
@@ -170,10 +248,37 @@ abstract class Tree {
      */
     function getMultipleNodes($paths) {
 
-        $result = [];
+        // Finding common parents
+        $parents = [];
         foreach($paths as $path) {
-            $result[$path] = $this->getNodeForPath($path);
+            list($parent, $node) = URLUtil::splitPath($path);
+            if (!isset($parents[$parent])) {
+                $parents[$parent] = [$node];
+            } else {
+                $parents[$parent][] = $node;
+            }
         }
+
+        $result = [];
+
+        foreach($parents as $parent=>$children) {
+
+            $parentNode = $this->getNodeForPath($parent);
+            if ($parentNode instanceof IMultiGet) {
+                foreach($parentNode->getMultipleChildren($children) as $childNode) {
+                    $fullPath = $parent . '/' . $childNode->getName();
+                    $result[$fullPath] = $childNode;
+                    $this->cache[$fullPath] = $childNode;
+                }
+            } else {
+                foreach($children as $child) {
+                    $fullPath = $parent . '/' . $child;
+                    $result[$fullPath] = $this->getNodeForPath($fullPath);
+                }
+            }
+
+        }
+
         return $result;
 
     }
diff --git a/lib/DAV/Tree/Filesystem.php b/lib/DAV/Tree/Filesystem.php
deleted file mode 100644
index ab34836..0000000
--- a/lib/DAV/Tree/Filesystem.php
+++ /dev/null
@@ -1,133 +0,0 @@
-<?php
-
-namespace Sabre\DAV\Tree;
-
-use Sabre\DAV;
-
-/**
- * FileSystem Tree
- *
- * This class is an alternative to the standard ObjectTree. This tree can only
- * use Sabre\DAV\FS\Directory and File classes, but as a result it allows for a few
- * optimizations that otherwise wouldn't be possible.
- *
- * Specifically copying and moving are much, much faster.
- *
- * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/).
- * @author Evert Pot (http://evertpot.com/)
- * @license http://sabre.io/license/ Modified BSD License
- */
-class Filesystem extends DAV\Tree {
-
-    /**
-     * Base url on the filesystem.
-     *
-     * @var string
-     */
-    protected $basePath;
-
-    /**
-     * Creates this tree
-     *
-     * Supply the path you'd like to share.
-     *
-     * @param string $basePath
-     */
-    public function __construct($basePath) {
-
-        $this->basePath = $basePath;
-
-    }
-
-    /**
-     * Returns a new node for the given path
-     *
-     * @param string $path
-     * @return DAV\FS\Node
-     */
-    public function getNodeForPath($path) {
-
-        $realPath = $this->getRealPath($path);
-        if (!file_exists($realPath)) {
-            throw new DAV\Exception\NotFound('File at location ' . $realPath . ' not found');
-        }
-        if (is_dir($realPath)) {
-            return new DAV\FS\Directory($realPath);
-        } else {
-            return new DAV\FS\File($realPath);
-        }
-
-    }
-
-    /**
-     * Returns the real filesystem path for a webdav url.
-     *
-     * @param string $publicPath
-     * @return string
-     */
-    protected function getRealPath($publicPath) {
-
-        return rtrim($this->basePath,'/') . '/' . trim($publicPath,'/');
-
-    }
-
-    /**
-     * Copies a file or directory.
-     *
-     * This method must work recursively and delete the destination
-     * if it exists
-     *
-     * @param string $source
-     * @param string $destination
-     * @return void
-     */
-    public function copy($source,$destination) {
-
-        $source = $this->getRealPath($source);
-        $destination = $this->getRealPath($destination);
-        $this->realCopy($source,$destination);
-
-    }
-
-    /**
-     * Used by self::copy
-     *
-     * @param string $source
-     * @param string $destination
-     * @return void
-     */
-    protected function realCopy($source,$destination) {
-
-        if (is_file($source)) {
-            copy($source,$destination);
-        } else {
-            mkdir($destination);
-            foreach(scandir($source) as $subnode) {
-
-                if ($subnode=='.' || $subnode=='..') continue;
-                $this->realCopy($source.'/'.$subnode,$destination.'/'.$subnode);
-
-            }
-        }
-
-    }
-
-    /**
-     * Moves a file or directory recursively.
-     *
-     * If the destination exists, delete it first.
-     *
-     * @param string $source
-     * @param string $destination
-     * @return void
-     */
-    public function move($source,$destination) {
-
-        $source = $this->getRealPath($source);
-        $destination = $this->getRealPath($destination);
-        rename($source,$destination);
-
-    }
-
-}
-
diff --git a/tests/Sabre/CalDAV/PluginTest.php b/tests/Sabre/CalDAV/PluginTest.php
index 1140f9b..4d1af54 100644
--- a/tests/Sabre/CalDAV/PluginTest.php
+++ b/tests/Sabre/CalDAV/PluginTest.php
@@ -71,8 +71,7 @@ class PluginTest extends \PHPUnit_Framework_TestCase {
         $root->addChild($calendars);
         $root->addChild($principals);
 
-        $objectTree = new DAV\ObjectTree($root);
-        $this->server = new DAV\Server($objectTree);
+        $this->server = new DAV\Server($root);
         $this->server->sapi = new HTTP\SapiMock();
         $this->server->debugExceptions = true;
         $this->server->setBaseUri('/');
diff --git a/tests/Sabre/DAV/Auth/Backend/AbstractBasicTest.php b/tests/Sabre/DAV/Auth/Backend/AbstractBasicTest.php
index f960fac..5952fe0 100644
--- a/tests/Sabre/DAV/Auth/Backend/AbstractBasicTest.php
+++ b/tests/Sabre/DAV/Auth/Backend/AbstractBasicTest.php
@@ -29,7 +29,7 @@ class AbstractBasicTest extends \PHPUnit_Framework_TestCase {
     public function testAuthenticateUnknownUser() {
 
         $response = new HTTP\ResponseMock();
-        $tree = new DAV\ObjectTree(new DAV\SimpleCollection('bla'));
+        $tree = new DAV\Tree(new DAV\SimpleCollection('bla'));
         $server = new DAV\Server($tree);
         $server->httpResponse = $response;
 
@@ -47,7 +47,7 @@ class AbstractBasicTest extends \PHPUnit_Framework_TestCase {
     public function testAuthenticate() {
 
         $response = new HTTP\ResponseMock();
-        $tree = new DAV\ObjectTree(new DAV\SimpleCollection('bla'));
+        $tree = new DAV\Tree(new DAV\SimpleCollection('bla'));
         $server = new DAV\Server($tree);
         $server->httpResponse = $response;
 
diff --git a/tests/Sabre/DAV/Issue33Test.php b/tests/Sabre/DAV/Issue33Test.php
index 34dc0c1..4ccb42f 100644
--- a/tests/Sabre/DAV/Issue33Test.php
+++ b/tests/Sabre/DAV/Issue33Test.php
@@ -47,7 +47,7 @@ class Issue33Test extends \PHPUnit_Framework_TestCase {
 
         $dir->createDirectory('bar');
 
-        $tree = new ObjectTree($dir);
+        $tree = new Tree($dir);
         $tree->move('bar',urldecode('%C3%A0fo%C3%B3'));
 
         $node = $tree->getNodeForPath(urldecode('%C3%A0fo%C3%B3'));
@@ -89,7 +89,7 @@ class Issue33Test extends \PHPUnit_Framework_TestCase {
 
         $dir->createDirectory('bar');
 
-        $tree = new ObjectTree($dir);
+        $tree = new Tree($dir);
 
         $server = new Server($tree);
         $server->setBaseUri('/webdav/');
diff --git a/tests/Sabre/DAV/Locks/PluginTest.php b/tests/Sabre/DAV/Locks/PluginTest.php
index ccb897c..362cd97 100644
--- a/tests/Sabre/DAV/Locks/PluginTest.php
+++ b/tests/Sabre/DAV/Locks/PluginTest.php
@@ -894,7 +894,7 @@ class PluginTest extends DAV\AbstractServer {
     function testPutWithCorrectETag() {
 
         // We need an etag-enabled file node.
-        $tree = new DAV\ObjectTree(new DAV\FSExt\Directory(SABRE_TEMPDIR));
+        $tree = new DAV\Tree(new DAV\FSExt\Directory(SABRE_TEMPDIR));
         $this->server->tree = $tree;
 
         $etag = md5(file_get_contents(SABRE_TEMPDIR . '/test.txt'));
diff --git a/tests/Sabre/DAV/ObjectTreeTest.php b/tests/Sabre/DAV/ObjectTreeTest.php
index 330058b..9b7eeb9 100644
--- a/tests/Sabre/DAV/ObjectTreeTest.php
+++ b/tests/Sabre/DAV/ObjectTreeTest.php
@@ -16,7 +16,7 @@ class ObjectTreeTest extends \PHPUnit_Framework_TestCase {
         file_put_contents(SABRE_TEMPDIR . '/root/file.txt','contents');
         file_put_contents(SABRE_TEMPDIR . '/root/subdir/subfile.txt','subcontents');
         $rootNode = new FSExt\Directory(SABRE_TEMPDIR . '/root');
-        $this->tree = new ObjectTree($rootNode);
+        $this->tree = new Tree($rootNode);
 
     }
 
diff --git a/tests/Sabre/DAV/ServerCopyMoveTest.php b/tests/Sabre/DAV/ServerCopyMoveTest.php
index 3e5c0db..d9688ca 100644
--- a/tests/Sabre/DAV/ServerCopyMoveTest.php
+++ b/tests/Sabre/DAV/ServerCopyMoveTest.php
@@ -18,7 +18,7 @@ class ServerCopyMoveTest extends \PHPUnit_Framework_TestCase {
 
         $this->response = new HTTP\ResponseMock();
         $dir = new FS\Directory(SABRE_TEMPDIR);
-        $tree = new ObjectTree($dir);
+        $tree = new Tree($dir);
         $this->server = new Server($tree);
         $this->server->sapi = new HTTP\SapiMock();
         $this->server->debugExceptions = true;
diff --git a/tests/Sabre/DAV/ServerPropsTest.php b/tests/Sabre/DAV/ServerPropsTest.php
index 701b284..6b72979 100644
--- a/tests/Sabre/DAV/ServerPropsTest.php
+++ b/tests/Sabre/DAV/ServerPropsTest.php
@@ -230,7 +230,7 @@ class ServerPropsTest extends AbstractServer {
         $dir = new Mock\PropertiesCollection('root', []);
         $dir->failMode = 'updatepropsfalse';
 
-        $objectTree = new ObjectTree($dir);
+        $objectTree = new Tree($dir);
         $this->server->tree = $objectTree;
 
         $props = array(
@@ -253,7 +253,7 @@ class ServerPropsTest extends AbstractServer {
         $dir = new Mock\PropertiesCollection('root', []);
         $dir->failMode = 'updatepropsarray';
 
-        $objectTree = new ObjectTree($dir);
+        $objectTree = new Tree($dir);
         $this->server->tree = $objectTree;
 
         $props = array(
@@ -277,7 +277,7 @@ class ServerPropsTest extends AbstractServer {
         $dir = new Mock\PropertiesCollection('root', []);
         $dir->failMode = 'updatepropsobj';
 
-        $objectTree = new ObjectTree($dir);
+        $objectTree = new Tree($dir);
         $this->server->tree = $objectTree;
 
         $props = array(
diff --git a/tests/Sabre/DAV/Tree/FilesystemTest.php b/tests/Sabre/DAV/Tree/FilesystemTest.php
deleted file mode 100644
index 19b0846..0000000
--- a/tests/Sabre/DAV/Tree/FilesystemTest.php
+++ /dev/null
@@ -1,88 +0,0 @@
-<?php
-
-namespace Sabre\DAV\Tree;
-
-use Sabre\DAV;
-
-/**
- * @covers Sabre\DAV\Tree
- * @covers Sabre\DAV\Tree\Filesystem
- * @covers Sabre\DAV\FS\Node
- * @covers Sabre\DAV\FS\File
- * @covers Sabre\DAV\FS\Directory
- */
-class FilesystemTest extends \PHPUnit_Framework_TestCase {
-
-    function setUp() {
-
-        \Sabre\TestUtil::clearTempDir();
-        file_put_contents(SABRE_TEMPDIR. '/file.txt','Body');
-        mkdir(SABRE_TEMPDIR.'/dir');
-        file_put_contents(SABRE_TEMPDIR.'/dir/subfile.txt','Body');
-
-    }
-
-    function tearDown() {
-
-        \Sabre\TestUtil::clearTempDir();
-
-    }
-
-    function testGetNodeForPath_File() {
-
-        $fs = new Filesystem(SABRE_TEMPDIR);
-        $node = $fs->getNodeForPath('file.txt');
-        $this->assertTrue($node instanceof DAV\FS\File);
-
-    }
-
-    /**
-     * @expectedException \Sabre\DAV\Exception\NotFound
-     */
-    function testGetNodeForPath_DoesntExist() {
-
-        $fs = new Filesystem(SABRE_TEMPDIR);
-        $node = $fs->getNodeForPath('whoop/file.txt');
-
-    }
-
-    function testGetNodeForPath_Directory() {
-
-        $fs = new Filesystem(SABRE_TEMPDIR);
-        $node = $fs->getNodeForPath('dir');
-        $this->assertTrue($node instanceof DAV\FS\Directory);
-        $this->assertEquals('dir', $node->getName());
-        $this->assertInternalType('array', $node->getChildren());
-
-    }
-
-    function testCopy() {
-
-        $fs = new Filesystem(SABRE_TEMPDIR);
-        $fs->copy('file.txt','file2.txt');
-        $this->assertTrue(file_exists(SABRE_TEMPDIR . '/file2.txt'));
-        $this->assertEquals('Body',file_get_contents(SABRE_TEMPDIR . '/file2.txt'));
-
-    }
-
-    function testCopyDir() {
-
-        $fs = new Filesystem(SABRE_TEMPDIR);
-        $fs->copy('dir','dir2');
-        $this->assertTrue(file_exists(SABRE_TEMPDIR . '/dir2'));
-        $this->assertEquals('Body',file_get_contents(SABRE_TEMPDIR . '/dir2/subfile.txt'));
-
-    }
-
-    function testMove() {
-
-        $fs = new Filesystem(SABRE_TEMPDIR);
-        $fs->move('file.txt','file2.txt');
-        $this->assertTrue(file_exists(SABRE_TEMPDIR . '/file2.txt'));
-        $this->assertTrue(!file_exists(SABRE_TEMPDIR . '/file.txt'));
-        $this->assertEquals('Body',file_get_contents(SABRE_TEMPDIR . '/file2.txt'));
-
-    }
-
-
-}
diff --git a/tests/Sabre/DAVACL/PrincipalPropertySearchTest.php b/tests/Sabre/DAVACL/PrincipalPropertySearchTest.php
index bfaad94..7d7f1a7 100644
--- a/tests/Sabre/DAVACL/PrincipalPropertySearchTest.php
+++ b/tests/Sabre/DAVACL/PrincipalPropertySearchTest.php
@@ -17,7 +17,7 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase {
         $principals = new PrincipalCollection($backend);
         $dir->addChild($principals);
 
-        $fakeServer = new DAV\Server(new DAV\ObjectTree($dir));
+        $fakeServer = new DAV\Server($dir);
         $fakeServer->sapi = new HTTP\SapiMock();
         $fakeServer->httpResponse = new HTTP\ResponseMock();
         $fakeServer->debugExceptions = true;
diff --git a/tests/Sabre/DAVACL/PrincipalSearchPropertySetTest.php b/tests/Sabre/DAVACL/PrincipalSearchPropertySetTest.php
index 96ba526..64e31bc 100644
--- a/tests/Sabre/DAVACL/PrincipalSearchPropertySetTest.php
+++ b/tests/Sabre/DAVACL/PrincipalSearchPropertySetTest.php
@@ -17,7 +17,7 @@ class PrincipalSearchPropertySetTest extends \PHPUnit_Framework_TestCase {
         $principals = new PrincipalCollection($backend);
         $dir->addChild($principals);
 
-        $fakeServer = new DAV\Server(new DAV\ObjectTree($dir));
+        $fakeServer = new DAV\Server($dir);
         $fakeServer->sapi = new HTTP\SapiMock();
         $fakeServer->httpResponse = new HTTP\ResponseMock();
         $plugin = new Plugin($backend,'realm');
diff --git a/tests/Sabre/DAVACL/Property/PrincipalTest.php b/tests/Sabre/DAVACL/Property/PrincipalTest.php
index 785acaa..1972968 100644
--- a/tests/Sabre/DAVACL/Property/PrincipalTest.php
+++ b/tests/Sabre/DAVACL/Property/PrincipalTest.php
@@ -45,8 +45,8 @@ class PrincipalTest extends \PHPUnit_Framework_TestCase {
         $root->setAttribute('xmlns:d','DAV:');
 
         $doc->appendChild($root);
-        $objectTree = new DAV\ObjectTree(new DAV\SimpleCollection('rootdir'));
-        $server = new DAV\Server($objectTree);
+        $node = new DAV\SimpleCollection('rootdir');
+        $server = new DAV\Server($node);
 
         $prin->serialize($server, $root);
 
@@ -74,7 +74,7 @@ class PrincipalTest extends \PHPUnit_Framework_TestCase {
         $root->setAttribute('xmlns:d','DAV:');
 
         $doc->appendChild($root);
-        $objectTree = new DAV\ObjectTree(new DAV\SimpleCollection('rootdir'));
+        $objectTree = new DAV\Tree(new DAV\SimpleCollection('rootdir'));
         $server = new DAV\Server($objectTree);
 
         $prin->serialize($server, $root);
@@ -103,7 +103,7 @@ class PrincipalTest extends \PHPUnit_Framework_TestCase {
         $root->setAttribute('xmlns:d','DAV:');
 
         $doc->appendChild($root);
-        $objectTree = new DAV\ObjectTree(new DAV\SimpleCollection('rootdir'));
+        $objectTree = new DAV\Tree(new DAV\SimpleCollection('rootdir'));
         $server = new DAV\Server($objectTree);
 
         $prin->serialize($server, $root);

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



More information about the Pkg-owncloud-commits mailing list