[Pkg-owncloud-commits] [php-sabredav] 33/42: Testing MOVE for property storage.

David Prévot taffit at moszumanska.debian.org
Wed Oct 29 20:52:07 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 3a53506e00f11663a67ca8ffe886028c546d0451
Author: Evert Pot <me at evertpot.com>
Date:   Thu Oct 23 21:15:29 2014 -0400

    Testing MOVE for property storage.
    
    Fixes #460.
---
 tests/Sabre/DAV/Mock/File.php                  | 13 +++++++++++++
 tests/Sabre/DAV/PropertyStorage/PluginTest.php | 24 +++++++++++++++++++++++-
 tests/Sabre/DAVServerTest.php                  |  6 ++++++
 3 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/tests/Sabre/DAV/Mock/File.php b/tests/Sabre/DAV/Mock/File.php
index 2b25bbb..3890183 100644
--- a/tests/Sabre/DAV/Mock/File.php
+++ b/tests/Sabre/DAV/Mock/File.php
@@ -91,6 +91,19 @@ class File extends DAV\File {
     }
 
     /**
+     * Changes the name of the node.
+     *
+     * @return void
+     */
+    public function setName($newName) {
+
+        $this->parent->deleteChild($this->name);
+        $this->name = $newName;
+        $this->parent->createFile($newName, $this->contents);
+
+    }
+
+    /**
      * Returns the ETag for a file
      *
      * An ETag is a unique identifier representing the current version of the file. If the file changes, the ETag MUST change.
diff --git a/tests/Sabre/DAV/PropertyStorage/PluginTest.php b/tests/Sabre/DAV/PropertyStorage/PluginTest.php
index 26c113e..d880427 100644
--- a/tests/Sabre/DAV/PropertyStorage/PluginTest.php
+++ b/tests/Sabre/DAV/PropertyStorage/PluginTest.php
@@ -5,9 +5,10 @@ namespace Sabre\DAV\PropertyStorage;
 class PluginTest extends \Sabre\DAVServerTest {
 
     protected $backend;
-
     protected $plugin;
 
+    protected $setupFiles = true;
+
     function setUp() {
 
         parent::setUp();
@@ -56,6 +57,27 @@ class PluginTest extends \Sabre\DAVServerTest {
 
     }
 
+    function testMove() {
+
+        $this->server->tree->getNodeForPath('files')->createFile('source');
+        $this->server->updateProperties('files/source', ['{DAV:}displayname' => 'hi']);
+
+        $request = new \Sabre\HTTP\Request('MOVE', '/files/source', ['Destination' => '/files/dest']);
+        $this->assertHTTPStatus(201, $request);
+
+        $result = $this->server->getProperties('/files/dest', ['{DAV:}displayname']);
+
+        $this->assertEquals([
+            '{DAV:}displayname' => 'hi',
+        ], $result);
+
+        $this->server->tree->getNodeForPath('files')->createFile('source');
+        $result = $this->server->getProperties('/files/source', ['{DAV:}displayname']);
+
+        $this->assertEquals([], $result);
+
+    }
+
     /**
      * @depends testDeleteProperty
      */
diff --git a/tests/Sabre/DAVServerTest.php b/tests/Sabre/DAVServerTest.php
index 3a60de7..5d4ac79 100644
--- a/tests/Sabre/DAVServerTest.php
+++ b/tests/Sabre/DAVServerTest.php
@@ -26,6 +26,7 @@ abstract class DAVServerTest extends \PHPUnit_Framework_TestCase {
     protected $setupCalDAVScheduling = false;
     protected $setupCalDAVSubscriptions = false;
     protected $setupLocks = false;
+    protected $setupFiles = false;
 
     /**
      * An array with calendars. Every calendar should have
@@ -187,6 +188,11 @@ abstract class DAVServerTest extends \PHPUnit_Framework_TestCase {
                 $this->principalBackend
             );
         }
+        if ($this->setupFiles) {
+
+            $this->tree[] = new DAV\Mock\Collection('files');
+
+        }
 
     }
 

-- 
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