ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
IMipPluginTest.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Sabre\CalDAV\Schedule;
4 
8 
10 
11  function testGetPluginInfo() {
12 
13  $plugin = new IMipPlugin('system@example.com');
14  $this->assertEquals(
15  'imip',
16  $plugin->getPluginInfo()['name']
17  );
18 
19  }
20 
21  function testDeliverReply() {
22 
23  $message = new Message();
24  $message->sender = 'mailto:sender@example.org';
25  $message->senderName = 'Sender';
26  $message->recipient = 'mailto:recipient@example.org';
27  $message->recipientName = 'Recipient';
28  $message->method = 'REPLY';
29 
30  $ics = <<<ICS
31 BEGIN:VCALENDAR\r
32 METHOD:REPLY\r
33 BEGIN:VEVENT\r
34 SUMMARY:Birthday party\r
35 END:VEVENT\r
36 END:VCALENDAR\r
37 
38 ICS;
39 
40 
41  $message->message = Reader::read($ics);
42 
43  $result = $this->schedule($message);
44 
45  $expected = [
46  [
47  'to' => 'Recipient <recipient@example.org>',
48  'subject' => 'Re: Birthday party',
49  'body' => $ics,
50  'headers' => [
51  'Reply-To: Sender <sender@example.org>',
52  'From: system@example.org',
53  'Content-Type: text/calendar; charset=UTF-8; method=REPLY',
54  'X-Sabre-Version: ' . \Sabre\DAV\Version::VERSION,
55  ],
56  ]
57  ];
58 
59  $this->assertEquals($expected, $result);
60 
61  }
62 
64 
65  $message = new Message();
66  $message->sender = 'mailto:sender@example.org';
67  $message->senderName = 'Sender';
68  $message->recipient = 'http://example.org/recipient';
69  $message->recipientName = 'Recipient';
70  $message->method = 'REPLY';
71 
72  $ics = <<<ICS
73 BEGIN:VCALENDAR\r
74 METHOD:REPLY\r
75 BEGIN:VEVENT\r
76 SUMMARY:Birthday party\r
77 END:VEVENT\r
78 END:VCALENDAR\r
79 
80 ICS;
81 
82 
83  $message->message = Reader::read($ics);
84 
85  $result = $this->schedule($message);
86 
87  $expected = [];
88 
89  $this->assertEquals($expected, $result);
90 
91  }
92 
93  function testDeliverRequest() {
94 
95  $message = new Message();
96  $message->sender = 'mailto:sender@example.org';
97  $message->senderName = 'Sender';
98  $message->recipient = 'mailto:recipient@example.org';
99  $message->recipientName = 'Recipient';
100  $message->method = 'REQUEST';
101 
102  $ics = <<<ICS
103 BEGIN:VCALENDAR\r
104 METHOD:REQUEST\r
105 BEGIN:VEVENT\r
106 SUMMARY:Birthday party\r
107 END:VEVENT\r
108 END:VCALENDAR\r
109 
110 ICS;
111 
112 
113  $message->message = Reader::read($ics);
114 
115  $result = $this->schedule($message);
116 
117  $expected = [
118  [
119  'to' => 'Recipient <recipient@example.org>',
120  'subject' => 'Birthday party',
121  'body' => $ics,
122  'headers' => [
123  'Reply-To: Sender <sender@example.org>',
124  'From: system@example.org',
125  'Content-Type: text/calendar; charset=UTF-8; method=REQUEST',
126  'X-Sabre-Version: ' . \Sabre\DAV\Version::VERSION,
127  ],
128  ]
129  ];
130 
131  $this->assertEquals($expected, $result);
132 
133  }
134 
135  function testDeliverCancel() {
136 
137  $message = new Message();
138  $message->sender = 'mailto:sender@example.org';
139  $message->senderName = 'Sender';
140  $message->recipient = 'mailto:recipient@example.org';
141  $message->recipientName = 'Recipient';
142  $message->method = 'CANCEL';
143 
144  $ics = <<<ICS
145 BEGIN:VCALENDAR\r
146 METHOD:CANCEL\r
147 BEGIN:VEVENT\r
148 SUMMARY:Birthday party\r
149 END:VEVENT\r
150 END:VCALENDAR\r
151 
152 ICS;
153 
154 
155  $message->message = Reader::read($ics);
156 
157  $result = $this->schedule($message);
158 
159  $expected = [
160  [
161  'to' => 'Recipient <recipient@example.org>',
162  'subject' => 'Cancelled: Birthday party',
163  'body' => $ics,
164  'headers' => [
165  'Reply-To: Sender <sender@example.org>',
166  'From: system@example.org',
167  'Content-Type: text/calendar; charset=UTF-8; method=CANCEL',
168  'X-Sabre-Version: ' . \Sabre\DAV\Version::VERSION,
169  ],
170  ]
171  ];
172 
173  $this->assertEquals($expected, $result);
174  $this->assertEquals('1.1', substr($message->scheduleStatus, 0, 3));
175 
176  }
177 
179 
180  $plugin = new IMip\MockPlugin('system@example.org');
181 
182  $server = new Server();
183  $server->addPlugin($plugin);
184  $server->emit('schedule', [$message]);
185 
186  return $plugin->getSentEmails();
187 
188  }
189 
191 
192  $message = new Message();
193  $message->sender = 'mailto:sender@example.org';
194  $message->senderName = 'Sender';
195  $message->recipient = 'mailto:recipient@example.org';
196  $message->recipientName = 'Recipient';
197  $message->method = 'REQUEST';
198  $message->significantChange = false;
199 
200  $ics = <<<ICS
201 BEGIN:VCALENDAR\r
202 METHOD:REQUEST\r
203 BEGIN:VEVENT\r
204 SUMMARY:Birthday party\r
205 END:VEVENT\r
206 END:VCALENDAR\r
207 
208 ICS;
209 
210 
211  $message->message = Reader::read($ics);
212 
213  $result = $this->schedule($message);
214 
215  $expected = [];
216  $this->assertEquals($expected, $result);
217  $this->assertEquals('1.0', $message->getScheduleStatus()[0]);
218 
219  }
220 
221 }
$result
This is the abstract base class for both the Request and Response objects.
Definition: Message.php:14
$server
Definition: sabredav.php:48
const VERSION
Full version number.
Definition: Version.php:17
catch(Exception $e) $message
Main DAV server class.
Definition: Server.php:23
static read($data, $options=0, $charset='UTF-8')
Parses a vCard or iCalendar object, and returns the top component.
Definition: Reader.php:42