[Pkg-owncloud-commits] [php-sabredav] 07/42: #550 Don't select a shared calendar as schedule-default-calendar-URL, unit tests

David Prévot taffit at moszumanska.debian.org
Fri Nov 28 22:47:47 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 78a1af5dfad076f4c3beb535c12ab1476e7004ee
Author: Armin Hackmann <armin at fruux.com>
Date:   Wed Nov 12 15:56:45 2014 +0100

    #550 Don't select a shared calendar as schedule-default-calendar-URL, unit tests
---
 lib/CalDAV/Schedule/Plugin.php                     |  4 +--
 .../Sabre/CalDAV/Schedule/PluginPropertiesTest.php | 17 +++++++++++++
 ... => PluginPropertiesWithSharedCalendarTest.php} | 29 +++++++++++++++++++++-
 3 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/lib/CalDAV/Schedule/Plugin.php b/lib/CalDAV/Schedule/Plugin.php
index 3f76e34..38492d2 100644
--- a/lib/CalDAV/Schedule/Plugin.php
+++ b/lib/CalDAV/Schedule/Plugin.php
@@ -237,8 +237,8 @@ class Plugin extends ServerPlugin {
             ], 1);
 
             foreach($result as $child) {
-                if (!isset($child[200]['{DAV:}resourcetype']) || !$child[200]['{DAV:}resourcetype']->is('{' . self::NS_CALDAV . '}calendar')) {
-                    // Node is not a calendar.
+                if (!isset($child[200]['{DAV:}resourcetype']) || !$child[200]['{DAV:}resourcetype']->is('{' . self::NS_CALDAV . '}calendar') || $child[200]['{DAV:}resourcetype']->is('{http://calendarserver.org/ns/}shared')) {
+                    // Node is either not a calendar or a shared instance.
                     continue;
                 }
                 if (!isset($child[200][$sccs]) || in_array('VEVENT', $child[200][$sccs]->getValue())) {
diff --git a/tests/Sabre/CalDAV/Schedule/PluginPropertiesTest.php b/tests/Sabre/CalDAV/Schedule/PluginPropertiesTest.php
index 7a5f5b8..2a50763 100644
--- a/tests/Sabre/CalDAV/Schedule/PluginPropertiesTest.php
+++ b/tests/Sabre/CalDAV/Schedule/PluginPropertiesTest.php
@@ -11,6 +11,19 @@ class PluginPropertiesTest extends \Sabre\DAVServerTest {
     protected $setupCalDAV = true;
     protected $setupCalDAVScheduling = true;
 
+    function setUp() {
+
+        parent::setUp();
+        $this->caldavBackend->createCalendar(
+            'principals/user1',
+            'default',
+            [
+
+            ]
+        );
+
+    }
+
     function testPrincipalProperties() {
 
         $props = $this->server->getPropertiesForPath('/principals/user1',array(
@@ -43,6 +56,10 @@ class PluginPropertiesTest extends \Sabre\DAVServerTest {
         $prop = $props[0][200]['{urn:ietf:params:xml:ns:caldav}calendar-user-type'];
         $this->assertEquals('INDIVIDUAL',$prop);
 
+        $this->assertArrayHasKey('{urn:ietf:params:xml:ns:caldav}schedule-default-calendar-URL',$props[0][200]);
+        $prop = $props[0][200]['{urn:ietf:params:xml:ns:caldav}schedule-default-calendar-URL'];
+        $this->assertEquals('calendars/user1/default/',$prop->getHref());
+
     }
 
 }
diff --git a/tests/Sabre/CalDAV/Schedule/PluginPropertiesTest.php b/tests/Sabre/CalDAV/Schedule/PluginPropertiesWithSharedCalendarTest.php
similarity index 67%
copy from tests/Sabre/CalDAV/Schedule/PluginPropertiesTest.php
copy to tests/Sabre/CalDAV/Schedule/PluginPropertiesWithSharedCalendarTest.php
index 7a5f5b8..81313c8 100644
--- a/tests/Sabre/CalDAV/Schedule/PluginPropertiesTest.php
+++ b/tests/Sabre/CalDAV/Schedule/PluginPropertiesWithSharedCalendarTest.php
@@ -6,10 +6,33 @@ use Sabre\DAVACL;
 use Sabre\DAV;
 use Sabre\HTTP;
 
-class PluginPropertiesTest extends \Sabre\DAVServerTest {
+class PluginPropertiesWithSharedCalendarTest extends \Sabre\DAVServerTest {
 
     protected $setupCalDAV = true;
     protected $setupCalDAVScheduling = true;
+    protected $setupCalDAVSharing = true;
+
+    function setUp() {
+
+        parent::setUp();
+        $this->caldavBackend->createCalendar(
+            'principals/user1',
+            'shared',
+            [
+                '{http://calendarserver.org/ns/}shared-url' => new DAV\Property\Href('calendars/user2/default/'),
+                '{http://sabredav.org/ns}read-only' => false,
+                '{http://sabredav.org/ns}owner-principal' => 'principals/user2',
+            ]
+        );
+        $this->caldavBackend->createCalendar(
+            'principals/user1',
+            'default',
+            [
+
+            ]
+        );
+
+    }
 
     function testPrincipalProperties() {
 
@@ -43,6 +66,10 @@ class PluginPropertiesTest extends \Sabre\DAVServerTest {
         $prop = $props[0][200]['{urn:ietf:params:xml:ns:caldav}calendar-user-type'];
         $this->assertEquals('INDIVIDUAL',$prop);
 
+        $this->assertArrayHasKey('{urn:ietf:params:xml:ns:caldav}schedule-default-calendar-URL',$props[0][200]);
+        $prop = $props[0][200]['{urn:ietf:params:xml:ns:caldav}schedule-default-calendar-URL'];
+        $this->assertEquals('calendars/user1/default/',$prop->getHref());
+
     }
 
 }

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