[Pkg-owncloud-commits] [php-sabredav] 36/275: First scheduling test passes.
David Prévot
taffit at moszumanska.debian.org
Thu Sep 25 14:55:48 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 2268f883441af6ebc515142e696da6050cda621b
Author: Evert Pot <evert at rooftopsolutions.nl>
Date: Tue Jan 14 00:56:22 2014 -0500
First scheduling test passes.
---
lib/Sabre/CalDAV/Schedule/Plugin.php | 14 ++++++--
tests/Sabre/CalDAV/Backend/Mock.php | 3 +-
.../Sabre/CalDAV/Schedule/DeliverNewEventTest.php | 37 +++++++++++++++++++---
3 files changed, 46 insertions(+), 8 deletions(-)
diff --git a/lib/Sabre/CalDAV/Schedule/Plugin.php b/lib/Sabre/CalDAV/Schedule/Plugin.php
index 8bb6cd8..a07ba76 100644
--- a/lib/Sabre/CalDAV/Schedule/Plugin.php
+++ b/lib/Sabre/CalDAV/Schedule/Plugin.php
@@ -424,7 +424,12 @@ class Plugin extends ServerPlugin {
if (isset($attendee['CN'])) $iTipMessage->recipientName = (string)$attendee['CN'];
$iTipMessage->sender = strtolower(substr($organizer, 7));
- if (isset($vevent->ORGANIZER['CN'])) $iTipMessage->senderName = $vevent->ORGANIZER['CN'];
+ if (isset($vevent->ORGANIZER['CN'])) $iTipMessage->senderName = (string)$vevent->ORGANIZER['CN'];
+
+ // Skipping if sender matches the recipient
+ if ($iTipMessage->sender === $iTipMessage->recipient) {
+ continue;
+ }
$iTipMessage->method = 'REQUEST';
@@ -462,10 +467,15 @@ class Plugin extends ServerPlugin {
*/
public function deliver(ITipMessage $iTipMessage) {
+ /*
$iTipMessage->scheduleStatus =
$this->iMIPMessage($iTipMessage->sender, [$iTipMessage->recipient], $iTipMessage->message, '');
+ */
- file_put_contents('/tmp/schedulelog', print_r($iTipMessage, true), FILE_APPEND);
+ $this->server->emit('schedule', [$iTipMessage]);
+ if (!$iTipMessage->scheduleStatus) {
+ $iTipMessage->scheduleStatus='5.2;There was no system capable of delivering the scheduling message';
+ }
}
diff --git a/tests/Sabre/CalDAV/Backend/Mock.php b/tests/Sabre/CalDAV/Backend/Mock.php
index b4737b0..34805e8 100644
--- a/tests/Sabre/CalDAV/Backend/Mock.php
+++ b/tests/Sabre/CalDAV/Backend/Mock.php
@@ -167,7 +167,7 @@ class Mock extends AbstractBackend implements NotificationSupport, SharingSuppor
foreach($objects as $uri => &$object) {
$object['calendarid'] = $calendarId;
$object['uri'] = $uri;
-
+ $object['lastmodified'] = null;
}
return $objects;
@@ -193,6 +193,7 @@ class Mock extends AbstractBackend implements NotificationSupport, SharingSuppor
$object = $this->calendarData[$calendarId][$objectUri];
$object['calendarid'] = $calendarId;
$object['uri'] = $objectUri;
+ $object['lastmodified'] = null;
return $object;
}
diff --git a/tests/Sabre/CalDAV/Schedule/DeliverNewEventTest.php b/tests/Sabre/CalDAV/Schedule/DeliverNewEventTest.php
index 9ca0ff9..e249e69 100644
--- a/tests/Sabre/CalDAV/Schedule/DeliverNewEventTest.php
+++ b/tests/Sabre/CalDAV/Schedule/DeliverNewEventTest.php
@@ -3,7 +3,8 @@
namespace Sabre\CalDAV\Schedule;
use
- Sabre\HTTP\Request;
+ Sabre\HTTP\Request,
+ Sabre\VObject;
class DeliverNewEventTest extends \Sabre\DAVServerTest {
@@ -17,7 +18,7 @@ class DeliverNewEventTest extends \Sabre\DAVServerTest {
'principals/user1',
'default',
[
-
+
]
);
@@ -43,15 +44,41 @@ ATTENDEE;CN="Roxy Kesh";CUTYPE=INDIVIDUAL;EMAIL="roxannakesh at gmail.com";
SUMMARY:Just testing!
DTSTART;TZID=America/Toronto:20140107T100000
DTSTAMP:20140109T204422Z
-ORGANIZER;CN="Adminstrator":mailto:evertpot at gmail.com
+ORGANIZER;CN="Administrator":mailto:user1.sabredav at sabredav.org
SEQUENCE:4
END:VEVENT
END:VCALENDAR
ICS
-);
+ );
+
+ $messages = [];
+ $this->server->on('schedule', function($message) use (&$messages) {
+ $messages[] = $message;
+ });
+
$response = $this->request($request);
+
$this->assertEquals(201, $response->getStatus(), 'Incorrect status code received. Response body:' . $response->getBodyAsString());
- $this->markTestIncomplete('Need to test if the message gets delivered');
+
+ $result = $this->request(new Request('GET', '/calendars/user1/default/foo.ics'))->getBody();
+ $resultVObj = VObject\Reader::read($result);
+
+ $this->assertEquals(
+ '5.2;There was no system capable of delivering the scheduling message',
+ $resultVObj->VEVENT->ATTENDEE[1]['SCHEDULE-STATUS']->getValue()
+ );
+
+ $this->assertEquals(1, count($messages));
+ $message = $messages[0];
+
+ $this->assertInstanceOf('\Sabre\CalDAV\Schedule\ITipMessage', $message);
+ $this->assertEquals('roxannakesh at gmail.com', $message->recipient);
+ $this->assertEquals('Roxy Kesh', $message->recipientName);
+ $this->assertEquals('user1.sabredav at sabredav.org', $message->sender);
+ $this->assertEquals('Administrator', $message->senderName);
+ $this->assertEquals('REQUEST', $message->method);
+
+ $this->assertEquals('REQUEST', $message->message->METHOD->getValue());
}
--
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