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

Public Member Functions

 setUp ()
 
 testSimple ()
 
 testSetupWithoutCoreSharingPlugin ()
 @expectedException \LogicException More...
 
 testGetFeatures ()
 
 testBeforeGetShareableCalendar ()
 
 testBeforeGetSharedCalendar ()
 
 testUpdateResourceType ()
 
 testUpdatePropertiesPassThru ()
 
 testUnknownMethodNoPOST ()
 
 testUnknownMethodNoXML ()
 
 testUnknownMethodNoNode ()
 
 testShareRequest ()
 
 testShareRequestNoShareableCalendar ()
 
 testInviteReply ()
 
 testInviteBadXML ()
 
 testInviteWrongUrl ()
 
 testPublish ()
 
 testUnpublish ()
 
 testPublishWrongUrl ()
 
 testUnpublishWrongUrl ()
 
 testUnknownXmlDoc ()
 
- Public Member Functions inherited from Sabre\DAVServerTest
 setUp ()
 
 initializeEverything ()
 
 request ($request, $expectedStatus=null)
 Makes a request, and returns a response object. More...
 
 autoLogin ($userName)
 This function takes a username and sets the server in a state where this user is logged in, and no longer requires an authentication check. More...
 
 setUpTree ()
 Override this to provide your own Tree for your test-case. More...
 
 setUpBackends ()
 
 assertHttpStatus ($expectedStatus, HTTP\Request $req)
 

Protected Attributes

 $setupCalDAV = true
 
 $setupCalDAVSharing = true
 
 $setupACL = true
 
 $autoLogin = 'user1'
 
- Protected Attributes inherited from Sabre\DAVServerTest
 $setupCalDAV = false
 
 $setupCardDAV = false
 
 $setupACL = false
 
 $setupCalDAVSharing = false
 
 $setupCalDAVScheduling = false
 
 $setupCalDAVSubscriptions = false
 
 $setupCalDAVICSExport = false
 
 $setupLocks = false
 
 $setupFiles = false
 
 $setupSharing = false
 
 $setupPropertyStorage = false
 
 $caldavCalendars = []
 An array with calendars. More...
 
 $caldavCalendarObjects = []
 
 $carddavAddressBooks = []
 
 $carddavCards = []
 
 $server
 
 $tree = []
 
 $caldavBackend
 
 $carddavBackend
 
 $principalBackend
 
 $locksBackend
 
 $propertyStorageBackend
 
 $caldavPlugin
 
 $carddavPlugin
 
 $aclPlugin
 
 $caldavSharingPlugin
 
 $caldavSchedulePlugin
 
 $authPlugin
 
 $locksPlugin
 
 $sharingPlugin
 
 $propertyStoragePlugin
 
 $autoLogin = null
 If this string is set, we will automatically log in the user with this name. More...
 

Detailed Description

Definition at line 9 of file SharingPluginTest.php.

Member Function Documentation

◆ setUp()

Sabre\CalDAV\SharingPluginTest::setUp ( )

Reimplemented from Sabre\DAVServerTest.

Definition at line 16 of file SharingPluginTest.php.

16 {
17
18 $this->caldavCalendars = [
19 [
20 'principaluri' => 'principals/user1',
21 'id' => 1,
22 'uri' => 'cal1',
23 ],
24 [
25 'principaluri' => 'principals/user1',
26 'id' => 2,
27 'uri' => 'cal2',
29 ],
30 [
31 'principaluri' => 'principals/user1',
32 'id' => 3,
33 'uri' => 'cal3',
34 ],
35 ];
36
37 parent::setUp();
38
39 // Making the logged in user an admin, for full access:
40 $this->aclPlugin->adminPrincipals[] = 'principals/user2';
41
42 }

References Sabre\DAV\Sharing\Plugin\ACCESS_READWRITE.

◆ testBeforeGetShareableCalendar()

Sabre\CalDAV\SharingPluginTest::testBeforeGetShareableCalendar ( )

Definition at line 72 of file SharingPluginTest.php.

72 {
73
74 // Forcing the server to authenticate:
75 $this->authPlugin->beforeMethod(new HTTP\Request(), new HTTP\Response());
76 $props = $this->server->getProperties('calendars/user1/cal1', [
77 '{' . Plugin::NS_CALENDARSERVER . '}invite',
78 '{' . Plugin::NS_CALENDARSERVER . '}allowed-sharing-modes',
79 ]);
80
81 $this->assertInstanceOf('Sabre\\CalDAV\\Xml\\Property\\Invite', $props['{' . Plugin::NS_CALENDARSERVER . '}invite']);
82 $this->assertInstanceOf('Sabre\\CalDAV\\Xml\\Property\\AllowedSharingModes', $props['{' . Plugin::NS_CALENDARSERVER . '}allowed-sharing-modes']);
83
84 }
const NS_CALENDARSERVER
This is the namespace for the proprietary calendarserver extensions.
Definition: Plugin.php:38

References Sabre\CalDAV\Plugin\NS_CALENDARSERVER.

◆ testBeforeGetSharedCalendar()

Sabre\CalDAV\SharingPluginTest::testBeforeGetSharedCalendar ( )

Definition at line 86 of file SharingPluginTest.php.

86 {
87
88 $props = $this->server->getProperties('calendars/user1/cal2', [
89 '{' . Plugin::NS_CALENDARSERVER . '}shared-url',
90 '{' . Plugin::NS_CALENDARSERVER . '}invite',
91 ]);
92
93 $this->assertInstanceOf('Sabre\\CalDAV\\Xml\\Property\\Invite', $props['{' . Plugin::NS_CALENDARSERVER . '}invite']);
94 //$this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $props['{' . Plugin::NS_CALENDARSERVER . '}shared-url']);
95
96 }

References Sabre\CalDAV\Plugin\NS_CALENDARSERVER.

◆ testGetFeatures()

Sabre\CalDAV\SharingPluginTest::testGetFeatures ( )

Definition at line 66 of file SharingPluginTest.php.

66 {
67
68 $this->assertEquals(['calendarserver-sharing'], $this->caldavSharingPlugin->getFeatures());
69
70 }

◆ testInviteBadXML()

Sabre\CalDAV\SharingPluginTest::testInviteBadXML ( )

Definition at line 268 of file SharingPluginTest.php.

268 {
269
271 'REQUEST_METHOD' => 'POST',
272 'REQUEST_URI' => '/calendars/user1',
273 'CONTENT_TYPE' => 'text/xml',
274 ]);
275
276 $xml = '<?xml version="1.0"?>
277<cs:invite-reply xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:">
278</cs:invite-reply>
279';
280 $request->setBody($xml);
281 $response = $this->request($request);
282 $this->assertEquals(400, $response->status, $response->body);
283
284 }
foreach($paths as $path) $request
Definition: asyncclient.php:32
request($request, $expectedStatus=null)
Makes a request, and returns a response object.
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.
Definition: Sapi.php:107
$response

References $request, $response, $xml, Sabre\HTTP\Sapi\createFromServerArray(), Sabre\CalDAV\Plugin\NS_CALENDARSERVER, and Sabre\DAVServerTest\request().

+ Here is the call graph for this function:

◆ testInviteReply()

Sabre\CalDAV\SharingPluginTest::testInviteReply ( )

Definition at line 247 of file SharingPluginTest.php.

247 {
248
250 'REQUEST_METHOD' => 'POST',
251 'REQUEST_URI' => '/calendars/user1',
252 'CONTENT_TYPE' => 'text/xml',
253 ]);
254
255 $xml = '<?xml version="1.0"?>
256<cs:invite-reply xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:">
257 <cs:hosturl><d:href>/principals/owner</d:href></cs:hosturl>
258 <cs:invite-accepted />
259</cs:invite-reply>
260';
261
262 $request->setBody($xml);
263 $response = $this->request($request);
264 $this->assertEquals(200, $response->status, $response->body);
265
266 }

References $request, $response, $xml, Sabre\HTTP\Sapi\createFromServerArray(), Sabre\CalDAV\Plugin\NS_CALENDARSERVER, and Sabre\DAVServerTest\request().

+ Here is the call graph for this function:

◆ testInviteWrongUrl()

Sabre\CalDAV\SharingPluginTest::testInviteWrongUrl ( )

Definition at line 286 of file SharingPluginTest.php.

286 {
287
289 'REQUEST_METHOD' => 'POST',
290 'REQUEST_URI' => '/calendars/user1/cal1',
291 'CONTENT_TYPE' => 'text/xml',
292 ]);
293
294 $xml = '<?xml version="1.0"?>
295<cs:invite-reply xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:">
296 <cs:hosturl><d:href>/principals/owner</d:href></cs:hosturl>
297</cs:invite-reply>
298';
299 $request->setBody($xml);
300 $response = $this->request($request);
301 $this->assertEquals(501, $response->status, $response->body);
302
303 // If the plugin did not handle this request, it must ensure that the
304 // body is still accessible by other plugins.
305 $this->assertEquals($xml, $request->getBody(true));
306
307 }

References $request, $response, $xml, Sabre\HTTP\Sapi\createFromServerArray(), Sabre\CalDAV\Plugin\NS_CALENDARSERVER, and Sabre\DAVServerTest\request().

+ Here is the call graph for this function:

◆ testPublish()

Sabre\CalDAV\SharingPluginTest::testPublish ( )

Definition at line 309 of file SharingPluginTest.php.

309 {
310
311 $request = new HTTP\Request('POST', '/calendars/user1/cal1', ['Content-Type' => 'text/xml']);
312
313 $xml = '<?xml version="1.0"?>
314<cs:publish-calendar xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:" />
315';
316
317 $request->setBody($xml);
318
319 $response = $this->request($request);
320 $this->assertEquals(202, $response->status, $response->body);
321
322 }

References $request, $response, $xml, Sabre\CalDAV\Plugin\NS_CALENDARSERVER, and Sabre\DAVServerTest\request().

+ Here is the call graph for this function:

◆ testPublishWrongUrl()

Sabre\CalDAV\SharingPluginTest::testPublishWrongUrl ( )

Definition at line 344 of file SharingPluginTest.php.

344 {
345
346 $request = new HTTP\Request(
347 'POST',
348 '/calendars/user1',
349 ['Content-Type' => 'text/xml']
350 );
351
352 $xml = '<?xml version="1.0"?>
353<cs:publish-calendar xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:" />
354';
355
356 $request->setBody($xml);
357 $this->request($request, 501);
358
359 }

References $request, $xml, Sabre\CalDAV\Plugin\NS_CALENDARSERVER, and Sabre\DAVServerTest\request().

+ Here is the call graph for this function:

◆ testSetupWithoutCoreSharingPlugin()

Sabre\CalDAV\SharingPluginTest::testSetupWithoutCoreSharingPlugin ( )

@expectedException \LogicException

Definition at line 57 of file SharingPluginTest.php.

57 {
58
59 $server = new DAV\Server();
60 $server->addPlugin(
61 new SharingPlugin()
62 );
63
64 }

References Sabre\DAVServerTest\$server.

◆ testShareRequest()

Sabre\CalDAV\SharingPluginTest::testShareRequest ( )

Definition at line 172 of file SharingPluginTest.php.

172 {
173
174 $request = new HTTP\Request('POST', '/calendars/user1/cal1', ['Content-Type' => 'text/xml']);
175
176 $xml = <<<RRR
177<?xml version="1.0"?>
178<cs:share xmlns:cs="http://calendarserver.org/ns/" xmlns:d="DAV:">
179 <cs:set>
180 <d:href>mailto:joe@example.org</d:href>
181 <cs:common-name>Joe Shmoe</cs:common-name>
182 <cs:read-write />
183 </cs:set>
184 <cs:remove>
185 <d:href>mailto:nancy@example.org</d:href>
186 </cs:remove>
187</cs:share>
188RRR;
189
190 $request->setBody($xml);
191
192 $response = $this->request($request, 200);
193
194 $this->assertEquals(
195 [
196 new Sharee([
197 'href' => 'mailto:joe@example.org',
198 'properties' => [
199 '{DAV:}displayname' => 'Joe Shmoe',
200 ],
201 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_READWRITE,
202 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_NORESPONSE,
203 'comment' => '',
204 ]),
205 ],
206 $this->caldavBackend->getInvites(1)
207 );
208
209 // Wiping out tree cache
210 $this->server->tree->markDirty('');
211
212 // Verifying that the calendar is now marked shared.
213 $props = $this->server->getProperties('calendars/user1/cal1', ['{DAV:}resourcetype']);
214 $this->assertTrue(
215 $props['{DAV:}resourcetype']->is('{http://calendarserver.org/ns/}shared-owner')
216 );
217
218 }

References $request, $response, $xml, Sabre\DAVServerTest\request(), and Sabre\VObject\write().

+ Here is the call graph for this function:

◆ testShareRequestNoShareableCalendar()

Sabre\CalDAV\SharingPluginTest::testShareRequestNoShareableCalendar ( )

Definition at line 220 of file SharingPluginTest.php.

220 {
221
222 $request = new HTTP\Request(
223 'POST',
224 '/calendars/user1/cal2',
225 ['Content-Type' => 'text/xml']
226 );
227
228 $xml = '<?xml version="1.0"?>
229<cs:share xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:">
230 <cs:set>
231 <d:href>mailto:joe@example.org</d:href>
232 <cs:common-name>Joe Shmoe</cs:common-name>
233 <cs:read-write />
234 </cs:set>
235 <cs:remove>
236 <d:href>mailto:nancy@example.org</d:href>
237 </cs:remove>
238</cs:share>
239';
240
241 $request->setBody($xml);
242
243 $response = $this->request($request, 403);
244
245 }

References $request, $response, $xml, Sabre\CalDAV\Plugin\NS_CALENDARSERVER, and Sabre\DAVServerTest\request().

+ Here is the call graph for this function:

◆ testSimple()

Sabre\CalDAV\SharingPluginTest::testSimple ( )

Definition at line 44 of file SharingPluginTest.php.

44 {
45
46 $this->assertInstanceOf('Sabre\\CalDAV\\SharingPlugin', $this->server->getPlugin('caldav-sharing'));
47 $this->assertEquals(
48 'caldav-sharing',
49 $this->caldavSharingPlugin->getPluginInfo()['name']
50 );
51
52 }

◆ testUnknownMethodNoNode()

Sabre\CalDAV\SharingPluginTest::testUnknownMethodNoNode ( )

Definition at line 158 of file SharingPluginTest.php.

158 {
159
161 'REQUEST_METHOD' => 'POST',
162 'REQUEST_URI' => '/foo',
163 'CONTENT_TYPE' => 'text/xml',
164 ]);
165
166 $response = $this->request($request);
167
168 $this->assertEquals(501, $response->status, $response->body);
169
170 }

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

+ Here is the call graph for this function:

◆ testUnknownMethodNoPOST()

Sabre\CalDAV\SharingPluginTest::testUnknownMethodNoPOST ( )

Definition at line 131 of file SharingPluginTest.php.

131 {
132
134 'REQUEST_METHOD' => 'PATCH',
135 'REQUEST_URI' => '/',
136 ]);
137
138 $response = $this->request($request);
139
140 $this->assertEquals(501, $response->status, $response->body);
141
142 }

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

+ Here is the call graph for this function:

◆ testUnknownMethodNoXML()

Sabre\CalDAV\SharingPluginTest::testUnknownMethodNoXML ( )

Definition at line 144 of file SharingPluginTest.php.

144 {
145
147 'REQUEST_METHOD' => 'POST',
148 'REQUEST_URI' => '/',
149 'CONTENT_TYPE' => 'text/plain',
150 ]);
151
152 $response = $this->request($request);
153
154 $this->assertEquals(501, $response->status, $response->body);
155
156 }

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

+ Here is the call graph for this function:

◆ testUnknownXmlDoc()

Sabre\CalDAV\SharingPluginTest::testUnknownXmlDoc ( )

Definition at line 378 of file SharingPluginTest.php.

378 {
379
380
381 $request = new HTTP\Request(
382 'POST',
383 '/calendars/user1/cal2',
384 ['Content-Type' => 'text/xml']
385 );
386
387 $xml = '<?xml version="1.0"?>
388<cs:foo-bar xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:" />';
389
390 $request->setBody($xml);
391
392 $response = $this->request($request);
393 $this->assertEquals(501, $response->status, $response->body);
394
395 }

References $request, $response, $xml, Sabre\CalDAV\Plugin\NS_CALENDARSERVER, and Sabre\DAVServerTest\request().

+ Here is the call graph for this function:

◆ testUnpublish()

Sabre\CalDAV\SharingPluginTest::testUnpublish ( )

Definition at line 325 of file SharingPluginTest.php.

325 {
326
327 $request = new HTTP\Request(
328 'POST',
329 '/calendars/user1/cal1',
330 ['Content-Type' => 'text/xml']
331 );
332
333 $xml = '<?xml version="1.0"?>
334<cs:unpublish-calendar xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:" />
335';
336
337 $request->setBody($xml);
338
339 $response = $this->request($request);
340 $this->assertEquals(200, $response->status, $response->body);
341
342 }

References $request, $response, $xml, Sabre\CalDAV\Plugin\NS_CALENDARSERVER, and Sabre\DAVServerTest\request().

+ Here is the call graph for this function:

◆ testUnpublishWrongUrl()

Sabre\CalDAV\SharingPluginTest::testUnpublishWrongUrl ( )

Definition at line 361 of file SharingPluginTest.php.

361 {
362
363 $request = new HTTP\Request(
364 'POST',
365 '/calendars/user1',
366 ['Content-Type' => 'text/xml']
367 );
368 $xml = '<?xml version="1.0"?>
369<cs:unpublish-calendar xmlns:cs="' . Plugin::NS_CALENDARSERVER . '" xmlns:d="DAV:" />
370';
371
372 $request->setBody($xml);
373
374 $this->request($request, 501);
375
376 }

References $request, $xml, Sabre\CalDAV\Plugin\NS_CALENDARSERVER, and Sabre\DAVServerTest\request().

+ Here is the call graph for this function:

◆ testUpdatePropertiesPassThru()

Sabre\CalDAV\SharingPluginTest::testUpdatePropertiesPassThru ( )

Definition at line 119 of file SharingPluginTest.php.

119 {
120
121 $result = $this->server->updateProperties('calendars/user1/cal3', [
122 '{DAV:}foo' => 'bar',
123 ]);
124
125 $this->assertEquals([
126 '{DAV:}foo' => 200,
127 ], $result);
128
129 }
$result

References $result.

◆ testUpdateResourceType()

Sabre\CalDAV\SharingPluginTest::testUpdateResourceType ( )

Definition at line 98 of file SharingPluginTest.php.

98 {
99
100 $this->caldavBackend->updateInvites(1,
101 [
102 new Sharee([
103 'href' => 'mailto:joe@example.org',
104 ])
105 ]
106 );
107 $result = $this->server->updateProperties('calendars/user1/cal1', [
108 '{DAV:}resourcetype' => new DAV\Xml\Property\ResourceType(['{DAV:}collection'])
109 ]);
110
111 $this->assertEquals([
112 '{DAV:}resourcetype' => 200
113 ], $result);
114
115 $this->assertEquals(0, count($this->caldavBackend->getInvites(1)));
116
117 }

References $result.

Field Documentation

◆ $autoLogin

Sabre\CalDAV\SharingPluginTest::$autoLogin = 'user1'
protected

Definition at line 14 of file SharingPluginTest.php.

◆ $setupACL

Sabre\CalDAV\SharingPluginTest::$setupACL = true
protected

Definition at line 13 of file SharingPluginTest.php.

◆ $setupCalDAV

Sabre\CalDAV\SharingPluginTest::$setupCalDAV = true
protected

Definition at line 11 of file SharingPluginTest.php.

◆ $setupCalDAVSharing

Sabre\CalDAV\SharingPluginTest::$setupCalDAVSharing = true
protected

Definition at line 12 of file SharingPluginTest.php.


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