ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Sabre\CalDAV\ValidateICalTest Class Reference
+ Inheritance diagram for Sabre\CalDAV\ValidateICalTest:
+ Collaboration diagram for Sabre\CalDAV\ValidateICalTest:

Public Member Functions

 setUp ()
 
 request (HTTP\Request $request)
 
 testCreateFile ()
 
 testCreateFileValid ()
 
 testCreateFileNoVersion ()
 
 testCreateFileNoVersionFixed ()
 
 testCreateFileNoComponents ()
 
 testCreateFileNoUID ()
 
 testCreateFileVCard ()
 
 testCreateFile2Components ()
 
 testCreateFile2UIDS ()
 
 testCreateFileWrongComponent ()
 
 testUpdateFile ()
 
 testUpdateFileParsableBody ()
 
 testCreateFileInvalidComponent ()
 
 testUpdateFileInvalidComponent ()
 
 testCreateFileModified ()
 What we are testing here, is if we send in a latin1 character, the server should automatically transform this into UTF-8. More...
 

Protected Attributes

 $server
 
 $calBackend
 

Detailed Description

Definition at line 11 of file ValidateICalTest.php.

Member Function Documentation

◆ request()

◆ setUp()

Sabre\CalDAV\ValidateICalTest::setUp ( )

Definition at line 22 of file ValidateICalTest.php.

References $principalBackend, $response, and $tree.

22  {
23 
24  $calendars = [
25  [
26  'id' => 'calendar1',
27  'principaluri' => 'principals/admin',
28  'uri' => 'calendar1',
29  '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Xml\Property\SupportedCalendarComponentSet(['VEVENT', 'VTODO', 'VJOURNAL']),
30  ],
31  [
32  'id' => 'calendar2',
33  'principaluri' => 'principals/admin',
34  'uri' => 'calendar2',
35  '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Xml\Property\SupportedCalendarComponentSet(['VTODO', 'VJOURNAL']),
36  ]
37  ];
38 
39  $this->calBackend = new Backend\Mock($calendars, []);
40  $principalBackend = new DAVACL\PrincipalBackend\Mock();
41 
42  $tree = [
43  new CalendarRoot($principalBackend, $this->calBackend),
44  ];
45 
46  $this->server = new DAV\Server($tree);
47  $this->server->sapi = new HTTP\SapiMock();
48  $this->server->debugExceptions = true;
49 
50  $plugin = new Plugin();
51  $this->server->addPlugin($plugin);
52 
53  $response = new HTTP\ResponseMock();
54  $this->server->httpResponse = $response;
55 
56  }
$response
$principalBackend

◆ testCreateFile()

Sabre\CalDAV\ValidateICalTest::testCreateFile ( )

Definition at line 67 of file ValidateICalTest.php.

References $request, $response, Sabre\HTTP\Sapi\createFromServerArray(), and Sabre\CalDAV\ValidateICalTest\request().

67  {
68 
70  'REQUEST_METHOD' => 'PUT',
71  'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics',
72  ]);
73 
74  $response = $this->request($request);
75 
76  $this->assertEquals(415, $response->status);
77 
78  }
foreach($paths as $path) $request
Definition: asyncclient.php:32
request(HTTP\Request $request)
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.
Definition: Sapi.php:107
$response
+ Here is the call graph for this function:

◆ testCreateFile2Components()

Sabre\CalDAV\ValidateICalTest::testCreateFile2Components ( )

Definition at line 252 of file ValidateICalTest.php.

References $request, $response, Sabre\HTTP\Sapi\createFromServerArray(), and Sabre\CalDAV\ValidateICalTest\request().

252  {
253 
255  'REQUEST_METHOD' => 'PUT',
256  'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics',
257  ]);
258  $request->setBody("BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nUID:foo\r\nEND:VEVENT\r\nBEGIN:VJOURNAL\r\nUID:foo\r\nEND:VJOURNAL\r\nEND:VCALENDAR\r\n");
259 
260  $response = $this->request($request);
261 
262  $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
263 
264  }
foreach($paths as $path) $request
Definition: asyncclient.php:32
request(HTTP\Request $request)
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.
Definition: Sapi.php:107
$response
+ Here is the call graph for this function:

◆ testCreateFile2UIDS()

Sabre\CalDAV\ValidateICalTest::testCreateFile2UIDS ( )

Definition at line 266 of file ValidateICalTest.php.

References $request, $response, Sabre\HTTP\Sapi\createFromServerArray(), and Sabre\CalDAV\ValidateICalTest\request().

266  {
267 
269  'REQUEST_METHOD' => 'PUT',
270  'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics',
271  ]);
272  $request->setBody("BEGIN:VCALENDAR\r\nBEGIN:VTIMEZONE\r\nEND:VTIMEZONE\r\nBEGIN:VEVENT\r\nUID:foo\r\nEND:VEVENT\r\nBEGIN:VEVENT\r\nUID:bar\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n");
273 
274  $response = $this->request($request);
275 
276  $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
277 
278  }
foreach($paths as $path) $request
Definition: asyncclient.php:32
request(HTTP\Request $request)
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.
Definition: Sapi.php:107
$response
+ Here is the call graph for this function:

◆ testCreateFileInvalidComponent()

Sabre\CalDAV\ValidateICalTest::testCreateFileInvalidComponent ( )

Definition at line 343 of file ValidateICalTest.php.

References $request, $response, Sabre\HTTP\Sapi\createFromServerArray(), and Sabre\CalDAV\ValidateICalTest\request().

343  {
344 
346  'REQUEST_METHOD' => 'PUT',
347  'REQUEST_URI' => '/calendars/admin/calendar2/blabla.ics',
348  ]);
349  $request->setBody("BEGIN:VCALENDAR\r\nBEGIN:VTIMEZONE\r\nEND:VTIMEZONE\r\nBEGIN:VEVENT\r\nUID:foo\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n");
350 
351  $response = $this->request($request);
352 
353  $this->assertEquals(403, $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
354 
355  }
foreach($paths as $path) $request
Definition: asyncclient.php:32
request(HTTP\Request $request)
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.
Definition: Sapi.php:107
$response
+ Here is the call graph for this function:

◆ testCreateFileModified()

Sabre\CalDAV\ValidateICalTest::testCreateFileModified ( )

What we are testing here, is if we send in a latin1 character, the server should automatically transform this into UTF-8.

More importantly. If any transformation happens, the etag must no longer be returned by the server.

Definition at line 379 of file ValidateICalTest.php.

References $request, $response, and Sabre\CalDAV\ValidateICalTest\request().

379  {
380 
381  $request = new HTTP\Request(
382  'PUT',
383  '/calendars/admin/calendar1/blabla.ics'
384  );
385  $ics = <<<ICS
386 BEGIN:VCALENDAR
387 VERSION:2.0
388 PRODID:foo
389 BEGIN:VEVENT
390 UID:foo
391 SUMMARY:Meeting in M\xfcnster
392 DTSTAMP:20160406T052348Z
393 DTSTART:20160706T140000Z
394 END:VEVENT
395 END:VCALENDAR
396 ICS;
397 
398  $request->setBody($ics);
399 
400  $response = $this->request($request);
401 
402  $this->assertEquals(201, $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
403  $this->assertNull($response->getHeader('ETag'));
404 
405  }
foreach($paths as $path) $request
Definition: asyncclient.php:32
request(HTTP\Request $request)
$response
+ Here is the call graph for this function:

◆ testCreateFileNoComponents()

Sabre\CalDAV\ValidateICalTest::testCreateFileNoComponents ( )

Definition at line 203 of file ValidateICalTest.php.

References $request, $response, and Sabre\CalDAV\ValidateICalTest\request().

203  {
204 
205  $request = new HTTP\Request(
206  'PUT',
207  '/calendars/admin/calendar1/blabla.ics',
208  ['Prefer' => 'handling=strict']
209  );
210  $ics = <<<ICS
211 BEGIN:VCALENDAR
212 VERSION:2.0
213 PRODID:foo
214 END:VCALENDAR
215 ICS;
216 
217  $request->setBody($ics);
218 
219  $response = $this->request($request);
220  $this->assertEquals(403, $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
221 
222  }
foreach($paths as $path) $request
Definition: asyncclient.php:32
request(HTTP\Request $request)
$response
+ Here is the call graph for this function:

◆ testCreateFileNoUID()

Sabre\CalDAV\ValidateICalTest::testCreateFileNoUID ( )

Definition at line 224 of file ValidateICalTest.php.

References $request, $response, Sabre\HTTP\Sapi\createFromServerArray(), and Sabre\CalDAV\ValidateICalTest\request().

224  {
225 
227  'REQUEST_METHOD' => 'PUT',
228  'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics',
229  ]);
230  $request->setBody("BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n");
231 
232  $response = $this->request($request);
233 
234  $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
235 
236  }
foreach($paths as $path) $request
Definition: asyncclient.php:32
request(HTTP\Request $request)
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.
Definition: Sapi.php:107
$response
+ Here is the call graph for this function:

◆ testCreateFileNoVersion()

Sabre\CalDAV\ValidateICalTest::testCreateFileNoVersion ( )

Definition at line 122 of file ValidateICalTest.php.

References $request, $response, and Sabre\CalDAV\ValidateICalTest\request().

122  {
123 
124  $request = new HTTP\Request(
125  'PUT',
126  '/calendars/admin/calendar1/blabla.ics',
127  ['Prefer' => 'handling=strict']
128  );
129 
130  $ics = <<<ICS
131 BEGIN:VCALENDAR
132 PRODID:foo
133 BEGIN:VEVENT
134 UID:foo
135 DTSTAMP:20160406T052348Z
136 DTSTART:20160706T140000Z
137 END:VEVENT
138 END:VCALENDAR
139 ICS;
140 
141  $request->setBody($ics);
142 
143  $response = $this->request($request);
144 
145  $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
146 
147  }
foreach($paths as $path) $request
Definition: asyncclient.php:32
request(HTTP\Request $request)
$response
+ Here is the call graph for this function:

◆ testCreateFileNoVersionFixed()

Sabre\CalDAV\ValidateICalTest::testCreateFileNoVersionFixed ( )

Definition at line 149 of file ValidateICalTest.php.

References $request, $response, Sabre\CalDAV\ValidateICalTest\request(), and Sabre\DAV\Version\VERSION.

149  {
150 
151  $request = new HTTP\Request(
152  'PUT',
153  '/calendars/admin/calendar1/blabla.ics',
154  ['Prefer' => 'handling=lenient']
155  );
156 
157  $ics = <<<ICS
158 BEGIN:VCALENDAR
159 PRODID:foo
160 BEGIN:VEVENT
161 UID:foo
162 DTSTAMP:20160406T052348Z
163 DTSTART:20160706T140000Z
164 END:VEVENT
165 END:VCALENDAR
166 ICS;
167 
168  $request->setBody($ics);
169 
170  $response = $this->request($request);
171 
172  $this->assertEquals(201, $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
173  $this->assertEquals([
174  'X-Sabre-Version' => [DAV\Version::VERSION],
175  'Content-Length' => ['0'],
176  'X-Sabre-Ew-Gross' => ['iCalendar validation warning: VERSION MUST appear exactly once in a VCALENDAR component'],
177  ], $response->getHeaders());
178 
179  $ics = <<<ICS
180 BEGIN:VCALENDAR\r
181 VERSION:2.0\r
182 PRODID:foo\r
183 BEGIN:VEVENT\r
184 UID:foo\r
185 DTSTAMP:20160406T052348Z\r
186 DTSTART:20160706T140000Z\r
187 END:VEVENT\r
188 END:VCALENDAR\r
189 
190 ICS;
191 
192  $expected = [
193  'uri' => 'blabla.ics',
194  'calendardata' => $ics,
195  'calendarid' => 'calendar1',
196  'lastmodified' => null,
197  ];
198 
199  $this->assertEquals($expected, $this->calBackend->getCalendarObject('calendar1', 'blabla.ics'));
200 
201  }
foreach($paths as $path) $request
Definition: asyncclient.php:32
const VERSION
Full version number.
Definition: Version.php:17
request(HTTP\Request $request)
$response
+ Here is the call graph for this function:

◆ testCreateFileValid()

Sabre\CalDAV\ValidateICalTest::testCreateFileValid ( )

Definition at line 80 of file ValidateICalTest.php.

References $request, $response, Sabre\CalDAV\ValidateICalTest\request(), and Sabre\DAV\Version\VERSION.

80  {
81 
82  $request = new HTTP\Request(
83  'PUT',
84  '/calendars/admin/calendar1/blabla.ics',
85  ['Prefer' => 'handling=strict']
86  );
87 
88  $ics = <<<ICS
89 BEGIN:VCALENDAR
90 VERSION:2.0
91 PRODID:foo
92 BEGIN:VEVENT
93 UID:foo
94 DTSTAMP:20160406T052348Z
95 DTSTART:20160706T140000Z
96 END:VEVENT
97 END:VCALENDAR
98 ICS;
99 
100  $request->setBody($ics);
101 
102  $response = $this->request($request);
103 
104  $this->assertEquals(201, $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
105  $this->assertEquals([
106  'X-Sabre-Version' => [DAV\Version::VERSION],
107  'Content-Length' => ['0'],
108  'ETag' => ['"' . md5($ics) . '"'],
109  ], $response->getHeaders());
110 
111  $expected = [
112  'uri' => 'blabla.ics',
113  'calendardata' => $ics,
114  'calendarid' => 'calendar1',
115  'lastmodified' => null,
116  ];
117 
118  $this->assertEquals($expected, $this->calBackend->getCalendarObject('calendar1', 'blabla.ics'));
119 
120  }
foreach($paths as $path) $request
Definition: asyncclient.php:32
const VERSION
Full version number.
Definition: Version.php:17
request(HTTP\Request $request)
$response
+ Here is the call graph for this function:

◆ testCreateFileVCard()

Sabre\CalDAV\ValidateICalTest::testCreateFileVCard ( )

Definition at line 238 of file ValidateICalTest.php.

References $request, $response, Sabre\HTTP\Sapi\createFromServerArray(), and Sabre\CalDAV\ValidateICalTest\request().

238  {
239 
241  'REQUEST_METHOD' => 'PUT',
242  'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics',
243  ]);
244  $request->setBody("BEGIN:VCARD\r\nEND:VCARD\r\n");
245 
246  $response = $this->request($request);
247 
248  $this->assertEquals(415, $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
249 
250  }
foreach($paths as $path) $request
Definition: asyncclient.php:32
request(HTTP\Request $request)
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.
Definition: Sapi.php:107
$response
+ Here is the call graph for this function:

◆ testCreateFileWrongComponent()

Sabre\CalDAV\ValidateICalTest::testCreateFileWrongComponent ( )

Definition at line 280 of file ValidateICalTest.php.

References $request, $response, Sabre\HTTP\Sapi\createFromServerArray(), and Sabre\CalDAV\ValidateICalTest\request().

280  {
281 
283  'REQUEST_METHOD' => 'PUT',
284  'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics',
285  ]);
286  $request->setBody("BEGIN:VCALENDAR\r\nBEGIN:VTIMEZONE\r\nEND:VTIMEZONE\r\nBEGIN:VFREEBUSY\r\nUID:foo\r\nEND:VFREEBUSY\r\nEND:VCALENDAR\r\n");
287 
288  $response = $this->request($request);
289 
290  $this->assertEquals(403, $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
291 
292  }
foreach($paths as $path) $request
Definition: asyncclient.php:32
request(HTTP\Request $request)
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.
Definition: Sapi.php:107
$response
+ Here is the call graph for this function:

◆ testUpdateFile()

Sabre\CalDAV\ValidateICalTest::testUpdateFile ( )

Definition at line 294 of file ValidateICalTest.php.

References $request, $response, Sabre\HTTP\Sapi\createFromServerArray(), and Sabre\CalDAV\ValidateICalTest\request().

294  {
295 
296  $this->calBackend->createCalendarObject('calendar1', 'blabla.ics', 'foo');
298  'REQUEST_METHOD' => 'PUT',
299  'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics',
300  ]);
301 
302  $response = $this->request($request);
303 
304  $this->assertEquals(415, $response->status);
305 
306  }
foreach($paths as $path) $request
Definition: asyncclient.php:32
request(HTTP\Request $request)
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.
Definition: Sapi.php:107
$response
+ Here is the call graph for this function:

◆ testUpdateFileInvalidComponent()

Sabre\CalDAV\ValidateICalTest::testUpdateFileInvalidComponent ( )

Definition at line 357 of file ValidateICalTest.php.

References $request, $response, Sabre\HTTP\Sapi\createFromServerArray(), and Sabre\CalDAV\ValidateICalTest\request().

357  {
358 
359  $this->calBackend->createCalendarObject('calendar2', 'blabla.ics', 'foo');
361  'REQUEST_METHOD' => 'PUT',
362  'REQUEST_URI' => '/calendars/admin/calendar2/blabla.ics',
363  ]);
364  $request->setBody("BEGIN:VCALENDAR\r\nBEGIN:VTIMEZONE\r\nEND:VTIMEZONE\r\nBEGIN:VEVENT\r\nUID:foo\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n");
365 
366  $response = $this->request($request);
367 
368  $this->assertEquals(403, $response->status, 'Incorrect status returned! Full response body: ' . $response->body);
369 
370  }
foreach($paths as $path) $request
Definition: asyncclient.php:32
request(HTTP\Request $request)
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.
Definition: Sapi.php:107
$response
+ Here is the call graph for this function:

◆ testUpdateFileParsableBody()

Sabre\CalDAV\ValidateICalTest::testUpdateFileParsableBody ( )

Definition at line 308 of file ValidateICalTest.php.

References $request, $response, and Sabre\CalDAV\ValidateICalTest\request().

308  {
309 
310  $this->calBackend->createCalendarObject('calendar1', 'blabla.ics', 'foo');
311  $request = new HTTP\Request(
312  'PUT',
313  '/calendars/admin/calendar1/blabla.ics'
314  );
315  $ics = <<<ICS
316 BEGIN:VCALENDAR
317 VERSION:2.0
318 PRODID:foo
319 BEGIN:VEVENT
320 UID:foo
321 DTSTAMP:20160406T052348Z
322 DTSTART:20160706T140000Z
323 END:VEVENT
324 END:VCALENDAR
325 ICS;
326 
327  $request->setBody($ics);
328  $response = $this->request($request);
329 
330  $this->assertEquals(204, $response->status);
331 
332  $expected = [
333  'uri' => 'blabla.ics',
334  'calendardata' => $ics,
335  'calendarid' => 'calendar1',
336  'lastmodified' => null,
337  ];
338 
339  $this->assertEquals($expected, $this->calBackend->getCalendarObject('calendar1', 'blabla.ics'));
340 
341  }
foreach($paths as $path) $request
Definition: asyncclient.php:32
request(HTTP\Request $request)
$response
+ Here is the call graph for this function:

Field Documentation

◆ $calBackend

Sabre\CalDAV\ValidateICalTest::$calBackend
protected

Definition at line 20 of file ValidateICalTest.php.

◆ $server

Sabre\CalDAV\ValidateICalTest::$server
protected

Definition at line 16 of file ValidateICalTest.php.


The documentation for this class was generated from the following file: