[Pkg-owncloud-commits] [php-sabre-vobject] 99/106: Support for REQUEST-STATUS.

David Prévot taffit at moszumanska.debian.org
Fri Aug 22 15:11:10 UTC 2014


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

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

commit 570b79745bc3598638238d8a183f74d447b3318d
Author: Evert Pot <me at evertpot.com>
Date:   Sun Aug 17 01:41:48 2014 -0400

    Support for REQUEST-STATUS.
---
 ChangeLog.md                                    |   2 +
 lib/ITip/Broker.php                             |   5 +
 tests/VObject/ITip/BrokerProcessMessageTest.php | 389 +-----------------------
 tests/VObject/ITip/BrokerProcessReplyTest.php   | 374 +++++++++++++++++++++++
 tests/VObject/ITip/BrokerTester.php             |  62 ++++
 5 files changed, 444 insertions(+), 388 deletions(-)

diff --git a/ChangeLog.md b/ChangeLog.md
index 67f07c3..3eeb4a9 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -12,6 +12,8 @@ ChangeLog
 * #114: VTIMEZONE is retained when generating new REQUEST objects.
 * #114: Support for 'MAILTO:' style email addresses (in uppercase) in the iTip
   broker. This improves evolution support.
+* #115: Using REQUEST-STATUS from REPLY messages and now propegating that into
+  SCHEDULE-STATUS.
 
 3.3.0 (2014-08-07)
 ------------------
diff --git a/lib/ITip/Broker.php b/lib/ITip/Broker.php
index aebb024..b8a6443 100644
--- a/lib/ITip/Broker.php
+++ b/lib/ITip/Broker.php
@@ -300,10 +300,14 @@ class Broker {
             return null;
         }
         $instances = array();
+        $requestStatus = '2.0;Success';
         foreach($itipMessage->message->VEVENT as $vevent) {
             $recurId = isset($vevent->{'RECURRENCE-ID'})?$vevent->{'RECURRENCE-ID'}->getValue():'master';
             $attendee = $vevent->ATTENDEE;
             $instances[$recurId] = $attendee['PARTSTAT']->getValue();
+            if (isset($vevent->{'REQUEST-STATUS'})) {
+                $requestStatus = $vevent->{'REQUEST-STATUS'}->getValue();
+            }
         }
         $masterObject = null;
         foreach($existingObject->VEVENT as $vevent) {
@@ -318,6 +322,7 @@ class Broker {
                         if ($attendee->getValue() === $itipMessage->sender) {
                             $attendeeFound = true;
                             $attendee['PARTSTAT'] = $instances[$recurId];
+                            $attendee['SCHEDULE-STATUS'] = $requestStatus;
                             break;
                         }
                     }
diff --git a/tests/VObject/ITip/BrokerProcessMessageTest.php b/tests/VObject/ITip/BrokerProcessMessageTest.php
index 6855b8e..649df98 100644
--- a/tests/VObject/ITip/BrokerProcessMessageTest.php
+++ b/tests/VObject/ITip/BrokerProcessMessageTest.php
@@ -2,9 +2,7 @@
 
 namespace Sabre\VObject\ITip;
 
-use Sabre\VObject\Reader;
-
-class BrokerProcessMessageTest extends \PHPUnit_Framework_TestCase {
+class BrokerProcessMessageTest extends BrokerTester {
 
     function testRequestNew() {
 
@@ -167,389 +165,4 @@ ICS;
 
     }
 
-    function testReplyNoOriginal() {
-
-        $itip = <<<ICS
-BEGIN:VCALENDAR
-VERSION:2.0
-METHOD:REPLY
-BEGIN:VEVENT
-SEQUENCE:2
-UID:foobar
-ATTENDEE;PARTSTAT=ACCEPTED:mailto:foo at example.org
-ORGANIZER:mailto:bar at example.org
-END:VEVENT
-END:VCALENDAR
-ICS;
-
-        $old = null;
-        $expected = null;
-
-        $result = $this->process($itip, $old, $expected);
-
-    }
-
-    function testReplyAccept() {
-
-        $itip = <<<ICS
-BEGIN:VCALENDAR
-VERSION:2.0
-METHOD:REPLY
-BEGIN:VEVENT
-ATTENDEE;PARTSTAT=ACCEPTED:mailto:foo at example.org
-ORGANIZER:mailto:bar at example.org
-SEQUENCE:2
-UID:foobar
-END:VEVENT
-END:VCALENDAR
-ICS;
-
-        $old = <<<ICS
-BEGIN:VCALENDAR
-VERSION:2.0
-BEGIN:VEVENT
-SEQUENCE:2
-UID:foobar
-ATTENDEE:mailto:foo at example.org
-ORGANIZER:mailto:bar at example.org
-END:VEVENT
-END:VCALENDAR
-ICS;
-
-        $expected = <<<ICS
-BEGIN:VCALENDAR
-VERSION:2.0
-BEGIN:VEVENT
-SEQUENCE:2
-UID:foobar
-ATTENDEE;PARTSTAT=ACCEPTED:mailto:foo at example.org
-ORGANIZER:mailto:bar at example.org
-END:VEVENT
-END:VCALENDAR
-ICS;
-
-        $result = $this->process($itip, $old, $expected);
-
-    }
-
-    function testReplyPartyCrasher() {
-
-        $itip = <<<ICS
-BEGIN:VCALENDAR
-VERSION:2.0
-METHOD:REPLY
-BEGIN:VEVENT
-ATTENDEE;PARTSTAT=ACCEPTED:mailto:crasher at example.org
-ORGANIZER:mailto:bar at example.org
-SEQUENCE:2
-UID:foobar
-END:VEVENT
-END:VCALENDAR
-ICS;
-
-        $old = <<<ICS
-BEGIN:VCALENDAR
-VERSION:2.0
-BEGIN:VEVENT
-SEQUENCE:2
-UID:foobar
-ATTENDEE:mailto:foo at example.org
-ORGANIZER:mailto:bar at example.org
-END:VEVENT
-END:VCALENDAR
-ICS;
-
-        $expected = <<<ICS
-BEGIN:VCALENDAR
-VERSION:2.0
-BEGIN:VEVENT
-SEQUENCE:2
-UID:foobar
-ATTENDEE:mailto:foo at example.org
-ORGANIZER:mailto:bar at example.org
-ATTENDEE;PARTSTAT=ACCEPTED:mailto:crasher at example.org
-END:VEVENT
-END:VCALENDAR
-ICS;
-
-        $result = $this->process($itip, $old, $expected);
-
-    }
-
-    function testReplyNewException() {
-
-        // This is a reply to 1 instance of a recurring event. This should
-        // automatically create an exception.
-        $itip = <<<ICS
-BEGIN:VCALENDAR
-VERSION:2.0
-METHOD:REPLY
-BEGIN:VEVENT
-ATTENDEE;PARTSTAT=ACCEPTED:mailto:foo at example.org
-ORGANIZER:mailto:bar at example.org
-SEQUENCE:2
-RECURRENCE-ID:20140725T000000Z
-UID:foobar
-END:VEVENT
-END:VCALENDAR
-ICS;
-
-        $old = <<<ICS
-BEGIN:VCALENDAR
-VERSION:2.0
-BEGIN:VEVENT
-SEQUENCE:2
-UID:foobar
-RRULE:FREQ=DAILY
-DTSTART:20140724T000000Z
-ATTENDEE:mailto:foo at example.org
-ORGANIZER:mailto:bar at example.org
-END:VEVENT
-END:VCALENDAR
-ICS;
-
-        $expected = <<<ICS
-BEGIN:VCALENDAR
-VERSION:2.0
-BEGIN:VEVENT
-SEQUENCE:2
-UID:foobar
-RRULE:FREQ=DAILY
-DTSTART:20140724T000000Z
-ATTENDEE:mailto:foo at example.org
-ORGANIZER:mailto:bar at example.org
-END:VEVENT
-BEGIN:VEVENT
-SEQUENCE:2
-UID:foobar
-DTSTART:20140725T000000Z
-ATTENDEE;PARTSTAT=ACCEPTED:mailto:foo at example.org
-ORGANIZER:mailto:bar at example.org
-RECURRENCE-ID:20140725T000000Z
-END:VEVENT
-END:VCALENDAR
-ICS;
-
-        $result = $this->process($itip, $old, $expected);
-
-    }
-
-    function testReplyNewExceptionTz() {
-
-        // This is a reply to 1 instance of a recurring event. This should
-        // automatically create an exception.
-        $itip = <<<ICS
-BEGIN:VCALENDAR
-VERSION:2.0
-METHOD:REPLY
-BEGIN:VEVENT
-ATTENDEE;PARTSTAT=ACCEPTED:mailto:foo at example.org
-ORGANIZER:mailto:bar at example.org
-SEQUENCE:2
-RECURRENCE-ID;TZID=America/Toronto:20140725T000000
-UID:foobar
-END:VEVENT
-END:VCALENDAR
-ICS;
-
-        $old = <<<ICS
-BEGIN:VCALENDAR
-VERSION:2.0
-BEGIN:VEVENT
-SEQUENCE:2
-UID:foobar
-RRULE:FREQ=DAILY
-DTSTART;TZID=America/Toronto:20140724T000000
-ATTENDEE:mailto:foo at example.org
-ORGANIZER:mailto:bar at example.org
-END:VEVENT
-END:VCALENDAR
-ICS;
-
-        $expected = <<<ICS
-BEGIN:VCALENDAR
-VERSION:2.0
-BEGIN:VEVENT
-SEQUENCE:2
-UID:foobar
-RRULE:FREQ=DAILY
-DTSTART;TZID=America/Toronto:20140724T000000
-ATTENDEE:mailto:foo at example.org
-ORGANIZER:mailto:bar at example.org
-END:VEVENT
-BEGIN:VEVENT
-SEQUENCE:2
-UID:foobar
-DTSTART;TZID=America/Toronto:20140725T000000
-ATTENDEE;PARTSTAT=ACCEPTED:mailto:foo at example.org
-ORGANIZER:mailto:bar at example.org
-RECURRENCE-ID;TZID=America/Toronto:20140725T000000
-END:VEVENT
-END:VCALENDAR
-ICS;
-
-        $result = $this->process($itip, $old, $expected);
-
-    }
-
-    function testReplyPartyCrashCreateExcepton() {
-
-        // IN this test there's a recurring event that has an exception. The
-        // exception is missing the attendee.
-        //
-        // The attendee party crashes the instance, so it should show up in the
-        // resulting object.
-        $itip = <<<ICS
-BEGIN:VCALENDAR
-VERSION:2.0
-METHOD:REPLY
-BEGIN:VEVENT
-ATTENDEE;PARTSTAT=ACCEPTED;CN=Crasher!:mailto:crasher at example.org
-ORGANIZER:mailto:bar at example.org
-SEQUENCE:2
-RECURRENCE-ID:20140725T000000Z
-UID:foobar
-END:VEVENT
-END:VCALENDAR
-ICS;
-
-        $old = <<<ICS
-BEGIN:VCALENDAR
-VERSION:2.0
-BEGIN:VEVENT
-SEQUENCE:2
-UID:foobar
-RRULE:FREQ=DAILY
-DTSTART:20140724T000000Z
-ORGANIZER:mailto:bar at example.org
-END:VEVENT
-END:VCALENDAR
-ICS;
-
-        $expected = <<<ICS
-BEGIN:VCALENDAR
-VERSION:2.0
-BEGIN:VEVENT
-SEQUENCE:2
-UID:foobar
-RRULE:FREQ=DAILY
-DTSTART:20140724T000000Z
-ORGANIZER:mailto:bar at example.org
-END:VEVENT
-BEGIN:VEVENT
-SEQUENCE:2
-UID:foobar
-DTSTART:20140725T000000Z
-ORGANIZER:mailto:bar at example.org
-RECURRENCE-ID:20140725T000000Z
-ATTENDEE;PARTSTAT=ACCEPTED;CN=Crasher!:mailto:crasher at example.org
-END:VEVENT
-END:VCALENDAR
-ICS;
-
-        $result = $this->process($itip, $old, $expected);
-
-    }
-
-    function testReplyNewExceptionNoMasterEvent() {
-
-        /**
-         * This iTip message would normally create a new exception, but the
-         * server is not able to create this new instance, because there's no
-         * master event to clone from.
-         *
-         * This test checks if the message is ignored.
-         */
-        $itip = <<<ICS
-BEGIN:VCALENDAR
-VERSION:2.0
-METHOD:REPLY
-BEGIN:VEVENT
-ATTENDEE;PARTSTAT=ACCEPTED;CN=Crasher!:mailto:crasher at example.org
-ORGANIZER:mailto:bar at example.org
-SEQUENCE:2
-RECURRENCE-ID:20140725T000000Z
-UID:foobar
-END:VEVENT
-END:VCALENDAR
-ICS;
-
-        $old = <<<ICS
-BEGIN:VCALENDAR
-VERSION:2.0
-BEGIN:VEVENT
-SEQUENCE:2
-UID:foobar
-RRULE:FREQ=DAILY
-DTSTART:20140724T000000Z
-RECURRENCE-ID:20140724T000000Z
-ORGANIZER:mailto:bar at example.org
-END:VEVENT
-END:VCALENDAR
-ICS;
-
-        $expected = null;
-        $result = $this->process($itip, $old, $expected);
-
-    }
-    function process($input, $existingObject = null, $expected = false) {
-
-        $version = \Sabre\VObject\Version::VERSION;
-
-        $vcal = Reader::read($input);
-
-        foreach($vcal->getComponents() as $mainComponent) {
-            break;
-        }
-
-        $message = new Message();
-        $message->message = $vcal;
-        $message->method = isset($vcal->METHOD)?$vcal->METHOD->getValue():null;
-        $message->component = $mainComponent->name;
-        $message->uid = $mainComponent->uid->getValue();
-        $message->sequence = isset($vcal->VEVENT[0])?(string)$vcal->VEVENT[0]->SEQUENCE:null;
-
-        if ($message->method === 'REPLY') {
-
-            $message->sender = $mainComponent->ATTENDEE->getValue();
-            $message->senderName = isset($mainComponent->ATTENDEE['CN'])?$mainComponent->ATTENDEE['CN']->getValue():null;
-            $message->recipient = $mainComponent->ORGANIZER->getValue();
-            $message->recipientName = isset($mainComponent->ORGANIZER['CN'])?$mainComponent->ORGANIZER['CN']:null;
-
-        }
-
-        $broker = new Broker();
-
-        if (is_string($existingObject)) {
-            $existingObject = str_replace(
-                '%foo%',
-                "VERSION:2.0\nPRODID:-//Sabre//Sabre VObject $version//EN\nCALSCALE:GREGORIAN",
-                $existingObject
-            );
-            $existingObject = Reader::read($existingObject);
-        }
-
-        $result = $broker->processMessage($message, $existingObject);
-
-        if (is_string($expected)) {
-            $expected = str_replace(
-                '%foo%',
-                "VERSION:2.0\nPRODID:-//Sabre//Sabre VObject $version//EN\nCALSCALE:GREGORIAN",
-                $expected
-            );
-            $expected = str_replace("\n", "\r\n", $expected);
-
-        }
-        if ($result instanceof \Sabre\VObject\Component\VCalendar) {
-            $result = $result->serialize();
-            $result = rtrim($result,"\r\n");
-        }
-
-        $this->assertEquals(
-            $expected,
-            $result
-        );
-
-    }
-
 }
diff --git a/tests/VObject/ITip/BrokerProcessReplyTest.php b/tests/VObject/ITip/BrokerProcessReplyTest.php
index 6c7245b..324191b 100644
--- a/tests/VObject/ITip/BrokerProcessReplyTest.php
+++ b/tests/VObject/ITip/BrokerProcessReplyTest.php
@@ -4,5 +4,379 @@ namespace Sabre\VObject\ITip;
 
 class BrokerProcessReplyTest extends BrokerTester {
 
+    function testReplyNoOriginal() {
+
+        $itip = <<<ICS
+BEGIN:VCALENDAR
+VERSION:2.0
+METHOD:REPLY
+BEGIN:VEVENT
+SEQUENCE:2
+UID:foobar
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:foo at example.org
+ORGANIZER:mailto:bar at example.org
+END:VEVENT
+END:VCALENDAR
+ICS;
+
+        $old = null;
+        $expected = null;
+
+        $result = $this->process($itip, $old, $expected);
+
+    }
+
+    function testReplyAccept() {
+
+        $itip = <<<ICS
+BEGIN:VCALENDAR
+VERSION:2.0
+METHOD:REPLY
+BEGIN:VEVENT
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:foo at example.org
+ORGANIZER:mailto:bar at example.org
+SEQUENCE:2
+UID:foobar
+END:VEVENT
+END:VCALENDAR
+ICS;
+
+        $old = <<<ICS
+BEGIN:VCALENDAR
+VERSION:2.0
+BEGIN:VEVENT
+SEQUENCE:2
+UID:foobar
+ATTENDEE:mailto:foo at example.org
+ORGANIZER:mailto:bar at example.org
+END:VEVENT
+END:VCALENDAR
+ICS;
+
+        $expected = <<<ICS
+BEGIN:VCALENDAR
+VERSION:2.0
+BEGIN:VEVENT
+SEQUENCE:2
+UID:foobar
+ATTENDEE;PARTSTAT=ACCEPTED;SCHEDULE-STATUS="2.0;Success":mailto:foo at example
+ .org
+ORGANIZER:mailto:bar at example.org
+END:VEVENT
+END:VCALENDAR
+ICS;
+
+        $result = $this->process($itip, $old, $expected);
+
+    }
+
+    function testReplyRequestStatus() {
+
+        $itip = <<<ICS
+BEGIN:VCALENDAR
+VERSION:2.0
+METHOD:REPLY
+BEGIN:VEVENT
+UID:foobar
+REQUEST-STATUS:2.3;foo-bar!
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:foo at example.org
+ORGANIZER:mailto:bar at example.org
+SEQUENCE:2
+UID:foobar
+END:VEVENT
+END:VCALENDAR
+ICS;
+
+        $old = <<<ICS
+BEGIN:VCALENDAR
+VERSION:2.0
+BEGIN:VEVENT
+UID:foobar
+SEQUENCE:2
+ATTENDEE:mailto:foo at example.org
+ORGANIZER:mailto:bar at example.org
+END:VEVENT
+END:VCALENDAR
+ICS;
+
+        $expected = <<<ICS
+BEGIN:VCALENDAR
+VERSION:2.0
+BEGIN:VEVENT
+UID:foobar
+SEQUENCE:2
+ATTENDEE;PARTSTAT=ACCEPTED;SCHEDULE-STATUS="2.3;foo-bar!":mailto:foo at exampl
+ e.org
+ORGANIZER:mailto:bar at example.org
+END:VEVENT
+END:VCALENDAR
+ICS;
+
+        $result = $this->process($itip, $old, $expected);
+
+    }
+
+
+    function testReplyPartyCrasher() {
+
+        $itip = <<<ICS
+BEGIN:VCALENDAR
+VERSION:2.0
+METHOD:REPLY
+BEGIN:VEVENT
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:crasher at example.org
+ORGANIZER:mailto:bar at example.org
+SEQUENCE:2
+UID:foobar
+END:VEVENT
+END:VCALENDAR
+ICS;
+
+        $old = <<<ICS
+BEGIN:VCALENDAR
+VERSION:2.0
+BEGIN:VEVENT
+SEQUENCE:2
+UID:foobar
+ATTENDEE:mailto:foo at example.org
+ORGANIZER:mailto:bar at example.org
+END:VEVENT
+END:VCALENDAR
+ICS;
+
+        $expected = <<<ICS
+BEGIN:VCALENDAR
+VERSION:2.0
+BEGIN:VEVENT
+SEQUENCE:2
+UID:foobar
+ATTENDEE:mailto:foo at example.org
+ORGANIZER:mailto:bar at example.org
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:crasher at example.org
+END:VEVENT
+END:VCALENDAR
+ICS;
+
+        $result = $this->process($itip, $old, $expected);
+
+    }
+
+    function testReplyNewException() {
+
+        // This is a reply to 1 instance of a recurring event. This should
+        // automatically create an exception.
+        $itip = <<<ICS
+BEGIN:VCALENDAR
+VERSION:2.0
+METHOD:REPLY
+BEGIN:VEVENT
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:foo at example.org
+ORGANIZER:mailto:bar at example.org
+SEQUENCE:2
+RECURRENCE-ID:20140725T000000Z
+UID:foobar
+END:VEVENT
+END:VCALENDAR
+ICS;
+
+        $old = <<<ICS
+BEGIN:VCALENDAR
+VERSION:2.0
+BEGIN:VEVENT
+SEQUENCE:2
+UID:foobar
+RRULE:FREQ=DAILY
+DTSTART:20140724T000000Z
+ATTENDEE:mailto:foo at example.org
+ORGANIZER:mailto:bar at example.org
+END:VEVENT
+END:VCALENDAR
+ICS;
+
+        $expected = <<<ICS
+BEGIN:VCALENDAR
+VERSION:2.0
+BEGIN:VEVENT
+SEQUENCE:2
+UID:foobar
+RRULE:FREQ=DAILY
+DTSTART:20140724T000000Z
+ATTENDEE:mailto:foo at example.org
+ORGANIZER:mailto:bar at example.org
+END:VEVENT
+BEGIN:VEVENT
+SEQUENCE:2
+UID:foobar
+DTSTART:20140725T000000Z
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:foo at example.org
+ORGANIZER:mailto:bar at example.org
+RECURRENCE-ID:20140725T000000Z
+END:VEVENT
+END:VCALENDAR
+ICS;
+
+        $result = $this->process($itip, $old, $expected);
+
+    }
+
+    function testReplyNewExceptionTz() {
+
+        // This is a reply to 1 instance of a recurring event. This should
+        // automatically create an exception.
+        $itip = <<<ICS
+BEGIN:VCALENDAR
+VERSION:2.0
+METHOD:REPLY
+BEGIN:VEVENT
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:foo at example.org
+ORGANIZER:mailto:bar at example.org
+SEQUENCE:2
+RECURRENCE-ID;TZID=America/Toronto:20140725T000000
+UID:foobar
+END:VEVENT
+END:VCALENDAR
+ICS;
+
+        $old = <<<ICS
+BEGIN:VCALENDAR
+VERSION:2.0
+BEGIN:VEVENT
+SEQUENCE:2
+UID:foobar
+RRULE:FREQ=DAILY
+DTSTART;TZID=America/Toronto:20140724T000000
+ATTENDEE:mailto:foo at example.org
+ORGANIZER:mailto:bar at example.org
+END:VEVENT
+END:VCALENDAR
+ICS;
+
+        $expected = <<<ICS
+BEGIN:VCALENDAR
+VERSION:2.0
+BEGIN:VEVENT
+SEQUENCE:2
+UID:foobar
+RRULE:FREQ=DAILY
+DTSTART;TZID=America/Toronto:20140724T000000
+ATTENDEE:mailto:foo at example.org
+ORGANIZER:mailto:bar at example.org
+END:VEVENT
+BEGIN:VEVENT
+SEQUENCE:2
+UID:foobar
+DTSTART;TZID=America/Toronto:20140725T000000
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:foo at example.org
+ORGANIZER:mailto:bar at example.org
+RECURRENCE-ID;TZID=America/Toronto:20140725T000000
+END:VEVENT
+END:VCALENDAR
+ICS;
+
+        $result = $this->process($itip, $old, $expected);
+
+    }
+
+    function testReplyPartyCrashCreateExcepton() {
+
+        // IN this test there's a recurring event that has an exception. The
+        // exception is missing the attendee.
+        //
+        // The attendee party crashes the instance, so it should show up in the
+        // resulting object.
+        $itip = <<<ICS
+BEGIN:VCALENDAR
+VERSION:2.0
+METHOD:REPLY
+BEGIN:VEVENT
+ATTENDEE;PARTSTAT=ACCEPTED;CN=Crasher!:mailto:crasher at example.org
+ORGANIZER:mailto:bar at example.org
+SEQUENCE:2
+RECURRENCE-ID:20140725T000000Z
+UID:foobar
+END:VEVENT
+END:VCALENDAR
+ICS;
+
+        $old = <<<ICS
+BEGIN:VCALENDAR
+VERSION:2.0
+BEGIN:VEVENT
+SEQUENCE:2
+UID:foobar
+RRULE:FREQ=DAILY
+DTSTART:20140724T000000Z
+ORGANIZER:mailto:bar at example.org
+END:VEVENT
+END:VCALENDAR
+ICS;
+
+        $expected = <<<ICS
+BEGIN:VCALENDAR
+VERSION:2.0
+BEGIN:VEVENT
+SEQUENCE:2
+UID:foobar
+RRULE:FREQ=DAILY
+DTSTART:20140724T000000Z
+ORGANIZER:mailto:bar at example.org
+END:VEVENT
+BEGIN:VEVENT
+SEQUENCE:2
+UID:foobar
+DTSTART:20140725T000000Z
+ORGANIZER:mailto:bar at example.org
+RECURRENCE-ID:20140725T000000Z
+ATTENDEE;PARTSTAT=ACCEPTED;CN=Crasher!:mailto:crasher at example.org
+END:VEVENT
+END:VCALENDAR
+ICS;
+
+        $result = $this->process($itip, $old, $expected);
+
+    }
+
+    function testReplyNewExceptionNoMasterEvent() {
+
+        /**
+         * This iTip message would normally create a new exception, but the
+         * server is not able to create this new instance, because there's no
+         * master event to clone from.
+         *
+         * This test checks if the message is ignored.
+         */
+        $itip = <<<ICS
+BEGIN:VCALENDAR
+VERSION:2.0
+METHOD:REPLY
+BEGIN:VEVENT
+ATTENDEE;PARTSTAT=ACCEPTED;CN=Crasher!:mailto:crasher at example.org
+ORGANIZER:mailto:bar at example.org
+SEQUENCE:2
+RECURRENCE-ID:20140725T000000Z
+UID:foobar
+END:VEVENT
+END:VCALENDAR
+ICS;
+
+        $old = <<<ICS
+BEGIN:VCALENDAR
+VERSION:2.0
+BEGIN:VEVENT
+SEQUENCE:2
+UID:foobar
+RRULE:FREQ=DAILY
+DTSTART:20140724T000000Z
+RECURRENCE-ID:20140724T000000Z
+ORGANIZER:mailto:bar at example.org
+END:VEVENT
+END:VCALENDAR
+ICS;
+
+        $expected = null;
+        $result = $this->process($itip, $old, $expected);
+
+    }
+
 
 }
diff --git a/tests/VObject/ITip/BrokerTester.php b/tests/VObject/ITip/BrokerTester.php
index 39b332d..a86da03 100644
--- a/tests/VObject/ITip/BrokerTester.php
+++ b/tests/VObject/ITip/BrokerTester.php
@@ -2,6 +2,8 @@
 
 namespace Sabre\VObject\ITip;
 
+use Sabre\VObject\Reader;
+
 /**
  * Utilities for testing the broker
  * 
@@ -38,4 +40,64 @@ abstract class BrokerTester extends \PHPUnit_Framework_TestCase {
         }
 
     }
+
+    function process($input, $existingObject = null, $expected = false) {
+
+        $version = \Sabre\VObject\Version::VERSION;
+
+        $vcal = Reader::read($input);
+
+        foreach($vcal->getComponents() as $mainComponent) {
+            break;
+        }
+
+        $message = new Message();
+        $message->message = $vcal;
+        $message->method = isset($vcal->METHOD)?$vcal->METHOD->getValue():null;
+        $message->component = $mainComponent->name;
+        $message->uid = $mainComponent->uid->getValue();
+        $message->sequence = isset($vcal->VEVENT[0])?(string)$vcal->VEVENT[0]->SEQUENCE:null;
+
+        if ($message->method === 'REPLY') {
+
+            $message->sender = $mainComponent->ATTENDEE->getValue();
+            $message->senderName = isset($mainComponent->ATTENDEE['CN'])?$mainComponent->ATTENDEE['CN']->getValue():null;
+            $message->recipient = $mainComponent->ORGANIZER->getValue();
+            $message->recipientName = isset($mainComponent->ORGANIZER['CN'])?$mainComponent->ORGANIZER['CN']:null;
+
+        }
+
+        $broker = new Broker();
+
+        if (is_string($existingObject)) {
+            $existingObject = str_replace(
+                '%foo%',
+                "VERSION:2.0\nPRODID:-//Sabre//Sabre VObject $version//EN\nCALSCALE:GREGORIAN",
+                $existingObject
+            );
+            $existingObject = Reader::read($existingObject);
+        }
+
+        $result = $broker->processMessage($message, $existingObject);
+
+        if (is_string($expected)) {
+            $expected = str_replace(
+                '%foo%',
+                "VERSION:2.0\nPRODID:-//Sabre//Sabre VObject $version//EN\nCALSCALE:GREGORIAN",
+                $expected
+            );
+            $expected = str_replace("\n", "\r\n", $expected);
+
+        }
+        if ($result instanceof \Sabre\VObject\Component\VCalendar) {
+            $result = $result->serialize();
+            $result = rtrim($result,"\r\n");
+        }
+
+        $this->assertEquals(
+            $expected,
+            $result
+        );
+
+    }
 }

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



More information about the Pkg-owncloud-commits mailing list