[Pkg-owncloud-commits] [php-sabredav] 143/275: IMip plugin is operational.

David Prévot taffit at moszumanska.debian.org
Thu Sep 25 14:56:01 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 75b996bc73f54560d2592a82d12d468481ca4343
Author: Evert Pot <me at evertpot.com>
Date:   Mon Aug 11 15:42:36 2014 -0400

    IMip plugin is operational.
---
 lib/CalDAV/Schedule/IMipPlugin.php                 |   7 +-
 .../Schedule/IMip/{Mock.php => MockPlugin.php}     |   2 +-
 tests/Sabre/CalDAV/Schedule/IMipPluginTest.php     | 150 +++++++++++++++++++++
 3 files changed, 155 insertions(+), 4 deletions(-)

diff --git a/lib/CalDAV/Schedule/IMipPlugin.php b/lib/CalDAV/Schedule/IMipPlugin.php
index 44d261b..4136bb2 100644
--- a/lib/CalDAV/Schedule/IMipPlugin.php
+++ b/lib/CalDAV/Schedule/IMipPlugin.php
@@ -70,7 +70,7 @@ class IMipPlugin extends DAV\ServerPlugin {
      * @param Server $server
      * @return void
      */
-    public function initalize(DAV\Server $server) {
+    public function initialize(DAV\Server $server) {
 
         $server->on('schedule', [$this, 'schedule']);
 
@@ -110,7 +110,7 @@ class IMipPlugin extends DAV\ServerPlugin {
         }
 
         $subject = 'SabreDAV iTIP message';
-        switch(strtoupper($vObject->METHOD)) {
+        switch(strtoupper($iTipMessage->method)) {
             case 'REPLY' :
                 $subject = 'Re: ' . $summary;
                 break;
@@ -131,11 +131,12 @@ class IMipPlugin extends DAV\ServerPlugin {
             $headers[] = 'X-Sabre-Version: ' . DAV\Version::VERSION;
         }
         $this->mail(
-            $iTipMessage->recipient,
+            $recipient,
             $subject,
             $iTipMessage->message->serialize(),
             $headers
         );
+        $iTipMessage->scheduleStatus = '1.1; Scheduling message is sent via iMip';
 
     }
 
diff --git a/tests/Sabre/CalDAV/Schedule/IMip/Mock.php b/tests/Sabre/CalDAV/Schedule/IMip/MockPlugin.php
similarity index 95%
rename from tests/Sabre/CalDAV/Schedule/IMip/Mock.php
rename to tests/Sabre/CalDAV/Schedule/IMip/MockPlugin.php
index c4e9ebb..b7aa77a 100644
--- a/tests/Sabre/CalDAV/Schedule/IMip/Mock.php
+++ b/tests/Sabre/CalDAV/Schedule/IMip/MockPlugin.php
@@ -16,7 +16,7 @@ namespace Sabre\CalDAV\Schedule\IMip;
  * @author Evert Pot (http://evertpot.com/)
  * @license http://sabre.io/license/ Modified BSD License
  */
-class Mock extends \Sabre\CalDAV\Schedule\IMip {
+class MockPlugin extends \Sabre\CalDAV\Schedule\IMipPlugin {
 
     protected $emails = array();
 
diff --git a/tests/Sabre/CalDAV/Schedule/IMipPluginTest.php b/tests/Sabre/CalDAV/Schedule/IMipPluginTest.php
new file mode 100644
index 0000000..799b143
--- /dev/null
+++ b/tests/Sabre/CalDAV/Schedule/IMipPluginTest.php
@@ -0,0 +1,150 @@
+<?php
+
+namespace Sabre\CalDAV\Schedule;
+
+use Sabre\VObject\ITip\Message;
+use Sabre\VObject\Reader;
+use Sabre\DAV\Server;
+
+class IMipPluginTest extends \PHPUnit_Framework_TestCase {
+
+    function testDeliverReply() {
+
+        $message = new Message();
+        $message->sender = 'sender at example.org';
+        $message->senderName = 'Sender';
+        $message->recipient = 'recipient at example.org';
+        $message->recipientName = 'Recipient';
+        $message->method = 'REPLY';
+
+        $ics = <<<ICS
+BEGIN:VCALENDAR\r
+METHOD:REPLY\r
+BEGIN:VEVENT\r
+SUMMARY:Birthday party\r
+END:VEVENT\r
+END:VCALENDAR\r
+
+ICS;
+
+
+        $message->message = Reader::read($ics);
+
+        $result = $this->schedule($message);
+
+        $expected = [
+            [
+                'to' => 'Recipient <recipient at example.org>',
+                'subject' => 'Re: Birthday party',
+                'body' => $ics,
+                'headers' => [
+                    'Reply-To: Sender <sender at example.org>',
+                    'From: system at example.org',
+                    'Content-Type: text/calendar; charset=UTF-8; method=REPLY',
+                    'X-Sabre-Version: ' . \Sabre\DAV\Version::VERSION,
+                ], 
+            ]
+        ];
+
+        $this->assertEquals($expected, $result);
+
+    }
+
+    function testDeliverRequest() {
+
+        $message = new Message();
+        $message->sender = 'sender at example.org';
+        $message->senderName = 'Sender';
+        $message->recipient = 'recipient at example.org';
+        $message->recipientName = 'Recipient';
+        $message->method = 'REQUEST';
+
+        $ics = <<<ICS
+BEGIN:VCALENDAR\r
+METHOD:REQUEST\r
+BEGIN:VEVENT\r
+SUMMARY:Birthday party\r
+END:VEVENT\r
+END:VCALENDAR\r
+
+ICS;
+
+
+        $message->message = Reader::read($ics);
+
+        $result = $this->schedule($message);
+
+        $expected = [
+            [
+                'to' => 'Recipient <recipient at example.org>',
+                'subject' => 'Birthday party',
+                'body' => $ics,
+                'headers' => [
+                    'Reply-To: Sender <sender at example.org>',
+                    'From: system at example.org',
+                    'Content-Type: text/calendar; charset=UTF-8; method=REQUEST',
+                    'X-Sabre-Version: ' . \Sabre\DAV\Version::VERSION,
+                ], 
+            ]
+        ];
+
+        $this->assertEquals($expected, $result);
+
+    }
+
+    function testDeliverCancel() {
+
+        $message = new Message();
+        $message->sender = 'sender at example.org';
+        $message->senderName = 'Sender';
+        $message->recipient = 'recipient at example.org';
+        $message->recipientName = 'Recipient';
+        $message->method = 'CANCEL';
+
+        $ics = <<<ICS
+BEGIN:VCALENDAR\r
+METHOD:CANCEL\r
+BEGIN:VEVENT\r
+SUMMARY:Birthday party\r
+END:VEVENT\r
+END:VCALENDAR\r
+
+ICS;
+
+
+        $message->message = Reader::read($ics);
+
+        $result = $this->schedule($message);
+
+        $expected = [
+            [
+                'to' => 'Recipient <recipient at example.org>',
+                'subject' => 'Cancelled: Birthday party',
+                'body' => $ics,
+                'headers' => [
+                    'Reply-To: Sender <sender at example.org>',
+                    'From: system at example.org',
+                    'Content-Type: text/calendar; charset=UTF-8; method=CANCEL',
+                    'X-Sabre-Version: ' . \Sabre\DAV\Version::VERSION,
+                ], 
+            ]
+        ];
+
+        $this->assertEquals($expected, $result);
+        $this->assertEquals('1.1', substr($message->scheduleStatus, 0, 3));
+
+    }
+
+    function schedule(Message $message) {
+
+        $plugin = new IMip\MockPlugin('system at example.org');
+
+        $server = new Server();
+        $server->addPlugin($plugin);
+        $server->emit('schedule', [$message]);
+
+        return $plugin->getSentEmails();
+
+    }
+
+}

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