ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
CreateSubscriptionTest.php
Go to the documentation of this file.
1<?php
2
4
7
9
10 protected $setupCalDAV = true;
11 protected $setupCalDAVSubscriptions = true;
12
16 function testMKCOL() {
17
18 $body = <<<XML
19<A:mkcol xmlns:A="DAV:">
20 <A:set>
21 <A:prop>
22 <B:subscribed-strip-attachments xmlns:B="http://calendarserver.org/ns/" />
23 <B:subscribed-strip-todos xmlns:B="http://calendarserver.org/ns/" />
24 <A:resourcetype>
25 <A:collection />
26 <B:subscribed xmlns:B="http://calendarserver.org/ns/" />
27 </A:resourcetype>
28 <E:calendar-color xmlns:E="http://apple.com/ns/ical/">#1C4587FF</E:calendar-color>
29 <A:displayname>Jewish holidays</A:displayname>
30 <C:calendar-description xmlns:C="urn:ietf:params:xml:ns:caldav">Foo</C:calendar-description>
31 <E:calendar-order xmlns:E="http://apple.com/ns/ical/">19</E:calendar-order>
32 <B:source xmlns:B="http://calendarserver.org/ns/">
33 <A:href>webcal://www.example.org/</A:href>
34 </B:source>
35 <E:refreshrate xmlns:E="http://apple.com/ns/ical/">P1W</E:refreshrate>
36 <B:subscribed-strip-alarms xmlns:B="http://calendarserver.org/ns/" />
37 </A:prop>
38 </A:set>
39</A:mkcol>
40XML;
41
42 $headers = [
43 'Content-Type' => 'application/xml',
44 ];
45 $request = new Request('MKCOL', '/calendars/user1/subscription1', $headers, $body);
46
47 $response = $this->request($request);
48 $this->assertEquals(201, $response->getStatus());
49 $subscriptions = $this->caldavBackend->getSubscriptionsForUser('principals/user1');
50 $this->assertSubscription($subscriptions[0]);
51
52
53 }
57 function testMKCALENDAR() {
58
59 $body = <<<XML
60<B:mkcalendar xmlns:B="urn:ietf:params:xml:ns:caldav">
61 <A:set xmlns:A="DAV:">
62 <A:prop>
63 <B:supported-calendar-component-set>
64 <B:comp name="VEVENT" />
65 </B:supported-calendar-component-set>
66 <C:subscribed-strip-alarms xmlns:C="http://calendarserver.org/ns/" />
67 <C:subscribed-strip-attachments xmlns:C="http://calendarserver.org/ns/" />
68 <A:resourcetype>
69 <A:collection />
70 <C:subscribed xmlns:C="http://calendarserver.org/ns/" />
71 </A:resourcetype>
72 <D:refreshrate xmlns:D="http://apple.com/ns/ical/">P1W</D:refreshrate>
73 <C:source xmlns:C="http://calendarserver.org/ns/">
74 <A:href>webcal://www.example.org/</A:href>
75 </C:source>
76 <D:calendar-color xmlns:D="http://apple.com/ns/ical/">#1C4587FF</D:calendar-color>
77 <D:calendar-order xmlns:D="http://apple.com/ns/ical/">19</D:calendar-order>
78 <B:calendar-description>Foo</B:calendar-description>
79 <C:subscribed-strip-todos xmlns:C="http://calendarserver.org/ns/" />
80 <A:displayname>Jewish holidays</A:displayname>
81 </A:prop>
82 </A:set>
83</B:mkcalendar>
84XML;
85
86 $headers = [
87 'Content-Type' => 'application/xml',
88 ];
89 $request = new Request('MKCALENDAR', '/calendars/user1/subscription1', $headers, $body);
90
91 $response = $this->request($request);
92 $this->assertEquals(201, $response->getStatus());
93 $subscriptions = $this->caldavBackend->getSubscriptionsForUser('principals/user1');
94 $this->assertSubscription($subscriptions[0]);
95
96 // Also seeing if it works when calling this as a PROPFIND.
97 $this->assertEquals([
98 '{http://calendarserver.org/ns/}subscribed-strip-alarms' => '',
99 ],
100 $this->server->getProperties('calendars/user1/subscription1', ['{http://calendarserver.org/ns/}subscribed-strip-alarms'])
101 );
102
103
104 }
105
106 function assertSubscription($subscription) {
107
108 $this->assertEquals('', $subscription['{http://calendarserver.org/ns/}subscribed-strip-attachments']);
109 $this->assertEquals('', $subscription['{http://calendarserver.org/ns/}subscribed-strip-todos']);
110 $this->assertEquals('#1C4587FF', $subscription['{http://apple.com/ns/ical/}calendar-color']);
111 $this->assertEquals('Jewish holidays', $subscription['{DAV:}displayname']);
112 $this->assertEquals('Foo', $subscription['{urn:ietf:params:xml:ns:caldav}calendar-description']);
113 $this->assertEquals('19', $subscription['{http://apple.com/ns/ical/}calendar-order']);
114 $this->assertEquals('webcal://www.example.org/', $subscription['{http://calendarserver.org/ns/}source']->getHref());
115 $this->assertEquals('P1W', $subscription['{http://apple.com/ns/ical/}refreshrate']);
116 $this->assertEquals('subscription1', $subscription['uri']);
117 $this->assertEquals('principals/user1', $subscription['principaluri']);
118 $this->assertEquals('webcal://www.example.org/', $subscription['source']);
119 $this->assertEquals(['principals/user1', 1], $subscription['id']);
120
121 }
122
123}
foreach($paths as $path) $request
Definition: asyncclient.php:32
An exception for terminatinating execution or to throw for unit testing.
This class may be used as a basis for other webdav-related unittests.
request($request, $expectedStatus=null)
Makes a request, and returns a response object.
The Request class represents a single HTTP request.
Definition: Request.php:18
if(PHP_SAPI !='cli') color
Definition: langcheck.php:120
$response