[Pkg-owncloud-commits] [php-sabre-vobject] 17/106: Generating attendee replies.
David Prévot
taffit at moszumanska.debian.org
Fri Aug 22 15:10:57 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 ba222d2499e6bc1193cc3eec7f295880e5976735
Author: Evert Pot <evert at rooftopsolutions.nl>
Date: Sat Jul 19 13:48:09 2014 -0400
Generating attendee replies.
---
lib/Sabre/VObject/ITip/Broker.php | 8 +-
.../Sabre/VObject/ITip/BrokerAttendeeReplyTest.php | 98 ++++++++++++++++++++++
2 files changed, 102 insertions(+), 4 deletions(-)
diff --git a/lib/Sabre/VObject/ITip/Broker.php b/lib/Sabre/VObject/ITip/Broker.php
index a579ff6..2df934e 100644
--- a/lib/Sabre/VObject/ITip/Broker.php
+++ b/lib/Sabre/VObject/ITip/Broker.php
@@ -193,7 +193,7 @@ class Broker {
// doing so if there's an oldCalendar, because we only want to
// process updates, not creation of new events.
foreach($eventInfo['attendees'] as $attendee) {
- if (in_array($attendee['href'], $userHrefs)) {
+ if (in_array($attendee['href'], $userHref)) {
return $this->parseEventForAttendee($calendar, $eventInfo, $oldEventInfo, $attendee['href']);
}
}
@@ -380,8 +380,8 @@ class Broker {
$message->method = 'REPLY';
$message->component = 'VEVENT';
$message->sequence = $eventInfo['sequence'];
- $message->sender = $attendee['href'];
- $message->senderName = $attendee['name'];
+ $message->sender = $attendee;
+ $message->senderName = $eventInfo['attendees'][$attendee]['name'];
$message->recipient = $eventInfo['organizer'];
$message->recipientName = $eventInfo['organizerName'];
@@ -409,7 +409,7 @@ class Broker {
$organizer['CN'] = $message->recipientName;
}
$attendee = $event->add('ATTENDEE', $message->sender, array(
- 'PARTSTAT' => $attendee['newstatus']
+ 'PARTSTAT' => $instance['newstatus']
));
if ($message->senderName) {
$attendee['CN'] = $message->senderName;
diff --git a/tests/Sabre/VObject/ITip/BrokerAttendeeReplyTest.php b/tests/Sabre/VObject/ITip/BrokerAttendeeReplyTest.php
new file mode 100644
index 0000000..8a5f755
--- /dev/null
+++ b/tests/Sabre/VObject/ITip/BrokerAttendeeReplyTest.php
@@ -0,0 +1,98 @@
+<?php
+
+namespace Sabre\VObject\ITip;
+
+class BrokerAttendeeReplyTest extends \PHPUnit_Framework_TestCase {
+
+ function testAccepted() {
+
+ $oldMessage = <<<ICS
+BEGIN:VCALENDAR
+VERSION:2.0
+BEGIN:VEVENT
+UID:foobar
+SEQUENCE:1
+ORGANIZER;CN=Strunk:mailto:strunk at example.org
+ATTENDEE;CN=One:mailto:one at example.org
+DTSTART:20140716T120000Z
+END:VEVENT
+END:VCALENDAR
+ICS;
+
+
+ $newMessage = <<<ICS
+BEGIN:VCALENDAR
+VERSION:2.0
+BEGIN:VEVENT
+UID:foobar
+SEQUENCE:1
+ORGANIZER;CN=Strunk:mailto:strunk at example.org
+ATTENDEE;PARTSTAT=ACCEPTED;CN=One:mailto:one at example.org
+DTSTART:20140716T120000Z
+END:VEVENT
+END:VCALENDAR
+ICS;
+
+ $version = \Sabre\VObject\Version::VERSION;
+
+ $expected = array(
+ array(
+ 'uid' => 'foobar',
+ 'method' => 'REPLY',
+ 'component' => 'VEVENT',
+ 'sender' => 'mailto:one at example.org',
+ 'senderName' => 'One',
+ 'recipient' => 'mailto:strunk at example.org',
+ 'recipientName' => 'Strunk',
+ 'message' => <<<ICS
+BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//Sabre//Sabre VObject $version//EN
+CALSCALE:GREGORIAN
+METHOD:REPLY
+BEGIN:VEVENT
+UID:foobar
+SEQUENCE:1
+ORGANIZER;CN=Strunk:mailto:strunk at example.org
+ATTENDEE;PARTSTAT=ACCEPTED;CN=One:mailto:one at example.org
+END:VEVENT
+END:VCALENDAR
+ICS
+
+ ),
+
+ );
+
+ $result = $this->parse($oldMessage, $newMessage, $expected);
+
+ }
+
+ function parse($oldMessage, $newMessage, $expected = array()) {
+
+ $broker = new Broker();
+ $result = $broker->parseEvent($newMessage, 'mailto:one at example.org', $oldMessage);
+
+ $this->assertEquals(count($expected), count($result));
+
+ foreach($expected as $index=>$ex) {
+
+ $message = $result[$index];
+
+ foreach($ex as $key=>$val) {
+
+ if ($key==='message') {
+ $this->assertEquals(
+ str_replace("\n", "\r\n", $val),
+ rtrim($message->message->serialize(), "\r\n")
+ );
+ } else {
+ $this->assertEquals($val, $message->$key);
+ }
+
+ }
+
+ }
+
+ }
+
+}
--
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