[Pkg-owncloud-commits] [php-sabredav] 124/148: Fixed lotsa bugs. Unittest mostly working.

David Prévot taffit at moszumanska.debian.org
Wed Apr 15 01:37:30 UTC 2015


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

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

commit 085a0a4ed43e1f94602077cfdf90443a09134c15
Author: Evert Pot <me at evertpot.com>
Date:   Sat Apr 11 19:34:41 2015 -0400

    Fixed lotsa bugs. Unittest mostly working.
---
 lib/CalDAV/Plugin.php                       |  5 +--
 lib/CardDAV/AddressBookHome.php             |  2 +-
 lib/CardDAV/Plugin.php                      | 22 ++++++-------
 lib/DAV/Server.php                          |  7 ++++-
 tests/Sabre/CalDAV/CalendarHomeTest.php     | 28 ++++++++++++-----
 tests/Sabre/CardDAV/AddressBookHomeTest.php | 10 +++---
 tests/Sabre/CardDAV/AddressBookRootTest.php |  2 +-
 tests/Sabre/CardDAV/PluginTest.php          | 49 -----------------------------
 8 files changed, 48 insertions(+), 77 deletions(-)

diff --git a/lib/CalDAV/Plugin.php b/lib/CalDAV/Plugin.php
index 520e453..5736764 100644
--- a/lib/CalDAV/Plugin.php
+++ b/lib/CalDAV/Plugin.php
@@ -6,6 +6,7 @@ use
     DateTimeZone,
     Sabre\DAV,
     Sabre\DAV\Exception\BadRequest,
+    Sabre\DAV\MkCol,
     Sabre\DAV\Xml\Property\Href,
     Sabre\DAVACL,
     Sabre\VObject,
@@ -287,7 +288,7 @@ class Plugin extends DAV\ServerPlugin {
             $resourceType = ['{DAV:}collection','{urn:ietf:params:xml:ns:caldav}calendar'];
         }
 
-        $this->server->createCollection($path,$resourceType,$properties);
+        $this->server->createCollection($path,new MkCol($resourceType, $properties));
 
         $this->server->httpResponse->setStatus(201);
         $this->server->httpResponse->setHeader('Content-Length',0);
@@ -926,7 +927,7 @@ class Plugin extends DAV\ServerPlugin {
         if (isset($postVars['{DAV:}displayname'])) {
             $properties['{DAV:}displayname'] = $postVars['{DAV:}displayname'];
         }
-        $this->server->createCollection($uri . '/' . $postVars['name'],$resourceType,$properties);
+        $this->server->createCollection($uri . '/' . $postVars['name'], new MkCol($resourceType,$properties));
         return false;
 
     }
diff --git a/lib/CardDAV/AddressBookHome.php b/lib/CardDAV/AddressBookHome.php
index 17b0172..7f5f2bf 100644
--- a/lib/CardDAV/AddressBookHome.php
+++ b/lib/CardDAV/AddressBookHome.php
@@ -169,7 +169,7 @@ class AddressBookHome extends DAV\Collection implements DAV\IExtendedCollection,
             throw new DAV\Exception\InvalidResourceType('Unknown resourceType for this collection');
         }
         $properties = $mkCol->getRemainingValues();
-        $mkCol->setRemainingStatus(201);
+        $mkCol->setRemainingResultCode(201);
         $this->carddavBackend->createAddressBook($this->principalUri, $name, $properties);
 
     }
diff --git a/lib/CardDAV/Plugin.php b/lib/CardDAV/Plugin.php
index a0b8217..19d8603 100644
--- a/lib/CardDAV/Plugin.php
+++ b/lib/CardDAV/Plugin.php
@@ -2,17 +2,17 @@
 
 namespace Sabre\CardDAV;
 
-use Sabre\DAV;
-use Sabre\DAVACL;
-use Sabre\VObject;
+use
+    Sabre\DAV,
+    Sabre\DAV\Exception\ReportNotSupported,
+    Sabre\DAV\MkCol,
+    Sabre\DAV\Xml\Property\Href,
+    Sabre\DAVACL,
+    Sabre\HTTP,
+    Sabre\HTTP\RequestInterface,
+    Sabre\HTTP\ResponseInterface,
+    Sabre\VObject;
 
-use Sabre\DAV\Exception\ReportNotSupported;
-
-use Sabre\HTTP;
-use Sabre\HTTP\RequestInterface;
-use Sabre\HTTP\ResponseInterface;
-
-use Sabre\DAV\Xml\Property\Href;
 
 /**
  * CardDAV plugin
@@ -800,7 +800,7 @@ class Plugin extends DAV\ServerPlugin {
         if (isset($postVars['{DAV:}displayname'])) {
             $properties['{DAV:}displayname'] = $postVars['{DAV:}displayname'];
         }
-        $this->server->createCollection($uri . '/' . $postVars['name'],$resourceType,$properties);
+        $this->server->createCollection($uri . '/' . $postVars['name'], new MkCol($resourceType,$properties));
         return false;
 
     }
diff --git a/lib/DAV/Server.php b/lib/DAV/Server.php
index ee50f64..a1a2714 100644
--- a/lib/DAV/Server.php
+++ b/lib/DAV/Server.php
@@ -1176,7 +1176,12 @@ class Server extends EventEmitter {
         }
         $success = $mkCol->commit();
 
-        if (!$success) return $mkCol->getResult();
+        if (!$success) {
+            $result = $mkCol->getResult();
+            // generateMkCol needs the href key to exist.
+            $result['href'] = $uri;
+            return $result;
+        }
 
         $this->tree->markDirty($parentUri);
         $this->emit('afterBind',[$uri]);
diff --git a/tests/Sabre/CalDAV/CalendarHomeTest.php b/tests/Sabre/CalDAV/CalendarHomeTest.php
index dd21129..518cc99 100644
--- a/tests/Sabre/CalDAV/CalendarHomeTest.php
+++ b/tests/Sabre/CalDAV/CalendarHomeTest.php
@@ -1,13 +1,13 @@
 <?php
 
 namespace Sabre\CalDAV;
-use Sabre\DAVACL;
-use Sabre\DAV;
 
-require_once 'Sabre/CalDAV/TestUtil.php';
+use
+    Sabre\DAV,
+    Sabre\DAV\MkCol,
+    Sabre\DAVACL;
+
 
-/**
- */
 class CalendarHomeTest extends \PHPUnit_Framework_TestCase {
 
     /**
@@ -161,7 +161,11 @@ class CalendarHomeTest extends \PHPUnit_Framework_TestCase {
      */
     function testCreateExtendedCollection() {
 
-        $result = $this->usercalendars->createExtendedCollection('newcalendar', array('{DAV:}collection', '{urn:ietf:params:xml:ns:caldav}calendar'), array());
+        $mkCol = new MkCol(
+            ['{DAV:}collection', '{urn:ietf:params:xml:ns:caldav}calendar'],
+            []
+        );
+        $result = $this->usercalendars->createExtendedCollection('newcalendar', $mkCol);
         $this->assertNull($result);
         $cals = $this->backend->getCalendarsForUser('principals/user1');
         $this->assertEquals(3,count($cals));
@@ -174,7 +178,11 @@ class CalendarHomeTest extends \PHPUnit_Framework_TestCase {
      */
     function testCreateExtendedCollectionBadResourceType() {
 
-        $this->usercalendars->createExtendedCollection('newcalendar', array('{DAV:}collection','{DAV:}blabla'), array());
+        $mkCol = new MkCol(
+            ['{DAV:}collection', '{DAV:}blabla'],
+            []
+        );
+        $this->usercalendars->createExtendedCollection('newcalendar', $mkCol);
 
     }
 
@@ -184,7 +192,11 @@ class CalendarHomeTest extends \PHPUnit_Framework_TestCase {
      */
     function testCreateExtendedCollectionNotACalendar() {
 
-        $this->usercalendars->createExtendedCollection('newcalendar', array('{DAV:}collection'), array());
+        $mkCol = new MkCol(
+            ['{DAV:}collection'],
+            []
+        );
+        $this->usercalendars->createExtendedCollection('newcalendar', $mkCol);
 
     }
 
diff --git a/tests/Sabre/CardDAV/AddressBookHomeTest.php b/tests/Sabre/CardDAV/AddressBookHomeTest.php
index cdf88ca..18ec255 100644
--- a/tests/Sabre/CardDAV/AddressBookHomeTest.php
+++ b/tests/Sabre/CardDAV/AddressBookHomeTest.php
@@ -2,6 +2,8 @@
 
 namespace Sabre\CardDAV;
 
+use Sabre\DAV\MkCol;
+
 class AddressBookHomeTest extends \PHPUnit_Framework_TestCase {
 
     /**
@@ -96,11 +98,11 @@ class AddressBookHomeTest extends \PHPUnit_Framework_TestCase {
 
     function testCreateExtendedCollection() {
 
-        $resourceType = array(
+        $resourceType = [ 
             '{' . Plugin::NS_CARDDAV . '}addressbook',
             '{DAV:}collection',
-        );
-        $this->s->createExtendedCollection('book2', $resourceType, array('{DAV:}displayname' => 'a-book 2'));
+        ];
+        $this->s->createExtendedCollection('book2', new MkCol($resourceType, ['{DAV:}displayname' => 'a-book 2']));
 
         $this->assertEquals(array(
             'id' => 'book2',
@@ -119,7 +121,7 @@ class AddressBookHomeTest extends \PHPUnit_Framework_TestCase {
         $resourceType = array(
             '{DAV:}collection',
         );
-        $this->s->createExtendedCollection('book2', $resourceType, array('{DAV:}displayname' => 'a-book 2'));
+        $this->s->createExtendedCollection('book2', new MkCol($resourceType, array('{DAV:}displayname' => 'a-book 2')));
 
     }
 
diff --git a/tests/Sabre/CardDAV/AddressBookRootTest.php b/tests/Sabre/CardDAV/AddressBookRootTest.php
index 6eaff5d..fc20480 100644
--- a/tests/Sabre/CardDAV/AddressBookRootTest.php
+++ b/tests/Sabre/CardDAV/AddressBookRootTest.php
@@ -24,7 +24,7 @@ class AddressBookRootTest extends \PHPUnit_Framework_TestCase {
         $children = $root->getChildren();
         $this->assertEquals(3, count($children));
 
-        $this->assertInstanceOf('Sabre\\CardDAV\\UserAddressBooks', $children[0]);
+        $this->assertInstanceOf('Sabre\\CardDAV\\AddressBookHome', $children[0]);
         $this->assertEquals('user1', $children[0]->getName());
 
     }
diff --git a/tests/Sabre/CardDAV/PluginTest.php b/tests/Sabre/CardDAV/PluginTest.php
index 3f95e66..a053e48 100644
--- a/tests/Sabre/CardDAV/PluginTest.php
+++ b/tests/Sabre/CardDAV/PluginTest.php
@@ -42,25 +42,6 @@ class PluginTest extends AbstractPluginTest {
 
     }
 
-    function testMeCardTest() {
-
-        $result = $this->server->getProperties(
-            'addressbooks/user1',
-            array(
-                '{http://calendarserver.org/ns/}me-card',
-            )
-        );
-
-        $this->assertEquals(
-            array(
-                '{http://calendarserver.org/ns/}me-card' =>
-                    new Href('addressbooks/user1/book1/vcard1.vcf')
-            ),
-            $result
-        );
-
-    }
-
     function testDirectoryGateway() {
 
         $result = $this->server->getProperties('principals/user1', array('{' . Plugin::NS_CARDDAV . '}directory-gateway'));
@@ -110,36 +91,6 @@ class PluginTest extends AbstractPluginTest {
 
     }
 
-    function testUpdatePropertiesMeCard() {
-
-        $result = $this->server->updateProperties('addressbooks/user1', [
-            '{http://calendarserver.org/ns/}me-card' => new Href('/addressbooks/user1/book1/vcard2',true),
-        ]);
-
-        $this->assertEquals(
-            [
-                '{http://calendarserver.org/ns/}me-card' => 200,
-            ],
-            $result
-        );
-
-    }
-
-    function testUpdatePropertiesMeCardBadValue() {
-
-        $result = $this->server->updateProperties('addressbooks/user1', [
-            '{http://calendarserver.org/ns/}me-card' => [],
-        ]);
-
-        $this->assertEquals(
-            [
-                '{http://calendarserver.org/ns/}me-card' => 400,
-            ],
-            $result
-        );
-
-    }
-
     function testAddressbookPluginProperties() {
 
         $ns = '{' . Plugin::NS_CARDDAV . '}';

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