[Pkg-owncloud-commits] [php-sabredav] 99/163: Testing jCal related functionality.

David Prévot taffit at moszumanska.debian.org
Tue May 20 18:54:58 UTC 2014


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

taffit pushed a commit to annotated tag upstream/2.0.0_beta1
in repository php-sabredav.

commit 21f6a328754c57e9cbf062253e213bbb3facb050
Author: Evert Pot <evert at rooftopsolutions.nl>
Date:   Mon Apr 28 23:43:22 2014 -0400

    Testing jCal related functionality.
---
 lib/Sabre/CalDAV/Subscriptions/ISubscription.php   |  5 +-
 tests/Sabre/CalDAV/CalendarQueryValidatorTest.php  | 14 ++++
 tests/Sabre/CalDAV/JCalTransformTest.php           | 80 ++++++++++++++++++++++
 .../Subscriptions/CreateSubscriptionTest.php       | 18 +++--
 4 files changed, 109 insertions(+), 8 deletions(-)

diff --git a/lib/Sabre/CalDAV/Subscriptions/ISubscription.php b/lib/Sabre/CalDAV/Subscriptions/ISubscription.php
index 3ee52a0..3795c39 100644
--- a/lib/Sabre/CalDAV/Subscriptions/ISubscription.php
+++ b/lib/Sabre/CalDAV/Subscriptions/ISubscription.php
@@ -2,9 +2,8 @@
 
 namespace Sabre\CalDAV\Subscriptions;
 
-use
-    Sabre\DAV\ICollection,
-    Sabre\DAV\IProperties;
+use Sabre\DAV\ICollection;
+use Sabre\DAV\IProperties;
 
 /**
  * ISubscription
diff --git a/tests/Sabre/CalDAV/CalendarQueryValidatorTest.php b/tests/Sabre/CalDAV/CalendarQueryValidatorTest.php
index 6330240..69d3a27 100644
--- a/tests/Sabre/CalDAV/CalendarQueryValidatorTest.php
+++ b/tests/Sabre/CalDAV/CalendarQueryValidatorTest.php
@@ -6,6 +6,20 @@ use Sabre\DAV;
 
 class CalendarQueryValidatorTest extends \PHPUnit_Framework_TestCase {
 
+    function testTopLevelFail() {
+
+        $validator = new CalendarQueryValidator();
+        $vcal = <<<ICS
+BEGIN:VCALENDAR
+BEGIN:VEVENT
+END:VEVENT
+END:VCALENDAR
+ICS;
+        $vcal = VObject\Reader::read($vcal);
+        $this->assertFalse($validator->validate($vcal, ['name' => 'VFOO']));
+
+    }
+
     /**
      * @dataProvider provider
      */
diff --git a/tests/Sabre/CalDAV/JCalTransformTest.php b/tests/Sabre/CalDAV/JCalTransformTest.php
new file mode 100644
index 0000000..d7a180e
--- /dev/null
+++ b/tests/Sabre/CalDAV/JCalTransformTest.php
@@ -0,0 +1,80 @@
+<?php
+
+namespace Sabre\CalDAV;
+
+use Sabre\HTTP\Request;
+
+class JCalTransformTest extends \Sabre\DAVServerTest {
+
+    protected $setupCalDAV = true;
+    protected $caldavCalendars = [
+        [
+            'id' => 1,
+            'principaluri' => 'principals/user1',
+            'uri' => 'foo',
+        ] 
+    ];
+    protected $caldavCalendarObjects = [
+        1 => [
+            'bar.ics' => [
+                'uri' => 'bar.ics',
+                'calendarid' => 1,
+                'calendardata' => "BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n",
+            ]
+        ],
+    ];
+
+    function testMultiGet() {
+
+        $xml = <<<XML
+<?xml version="1.0"?>
+<c:calendar-multiget xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:">
+    <d:prop>
+        <c:calendar-data content-type="application/calendar+json" />
+    </d:prop>
+    <d:href>/calendars/user1/foo/bar.ics</d:href>
+</c:calendar-multiget>
+XML;
+
+        $headers = [];
+        $request = new Request('REPORT', '/calendars/foo', $headers, $xml);
+
+        $response = $this->request($request);
+
+        $this->assertEquals(207, $response->getStatus());
+
+        $body = $response->getBodyAsString();
+
+        // Getting from the xml body to the actual returned data is 
+        // unfortunately very convoluted.
+        $responses = \Sabre\DAV\Property\ResponseList::unserialize(
+            \Sabre\DAV\XMLUtil::loadDOMDocument($body)->firstChild
+        , $this->server->propertyMap);
+
+        $responses = $responses->getResponses();
+        $this->assertEquals(1, count($responses));
+
+        $response = $responses[0]->getResponseProperties()[200]["{urn:ietf:params:xml:ns:caldav}calendar-data"];
+        
+        $response = json_decode($response,true);
+        if (json_last_error()) {
+            $this->fail('Json decoding error: ' . json_last_error_msg());
+        }
+        $this->assertEquals(
+            [
+                'vcalendar',
+                [],
+                [
+                    [
+                        'vevent',
+                        [],
+                        [],
+                    ],
+                ],
+            ],
+            $response
+        );
+
+    }
+
+}
diff --git a/tests/Sabre/CalDAV/Subscriptions/CreateSubscriptionTest.php b/tests/Sabre/CalDAV/Subscriptions/CreateSubscriptionTest.php
index 6085d6c..8ad0f8a 100644
--- a/tests/Sabre/CalDAV/Subscriptions/CreateSubscriptionTest.php
+++ b/tests/Sabre/CalDAV/Subscriptions/CreateSubscriptionTest.php
@@ -42,14 +42,14 @@ XML;
         $headers = [
             'Content-Type' => 'application/xml',
         ];
-        $request = new Request('MKCOL', '/calendars/user1/subscription1', $headers, $body); 
+        $request = new Request('MKCOL', '/calendars/user1/subscription1', $headers, $body);
 
         $response = $this->request($request);
         $this->assertEquals(201, $response->getStatus());
         $subscriptions = $this->caldavBackend->getSubscriptionsForUser('principals/user1');
-        $this->assertSubscription($subscriptions[0]); 
+        $this->assertSubscription($subscriptions[0]);
+
 
-    
     }
     /**
      * OS X 10.9.2 and up
@@ -86,12 +86,20 @@ XML;
         $headers = [
             'Content-Type' => 'application/xml',
         ];
-        $request = new Request('MKCALENDAR', '/calendars/user1/subscription1', $headers, $body); 
+        $request = new Request('MKCALENDAR', '/calendars/user1/subscription1', $headers, $body);
 
         $response = $this->request($request);
         $this->assertEquals(201, $response->getStatus());
         $subscriptions = $this->caldavBackend->getSubscriptionsForUser('principals/user1');
-        $this->assertSubscription($subscriptions[0]); 
+        $this->assertSubscription($subscriptions[0]);
+
+        // Also seeing if it works when calling this as a PROPFIND.
+        $this->assertEquals([
+                '{http://calendarserver.org/ns/}subscribed-strip-alarms' => '',
+            ],
+            $this->server->getProperties('calendars/user1/subscription1', ['{http://calendarserver.org/ns/}subscribed-strip-alarms'])
+        );
+
 
     }
 

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