ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ShareResourceTest.php
Go to the documentation of this file.
1<?php
2
3namespace Sabre\DAV\Sharing;
4
8
10
11 protected $setupSharing = true;
13
14 function setUpTree() {
15
16 $this->tree[] = $this->sharingNodeMock = new Mock\SharedNode(
17 'shareable',
19 );
20
21 }
22
23 function testShareResource() {
24
25 $body = <<<XML
26<?xml version="1.0" encoding="utf-8" ?>
27<D:share-resource xmlns:D="DAV:">
28 <D:sharee>
29 <D:href>mailto:eric@example.com</D:href>
30 <D:prop>
31 <D:displayname>Eric York</D:displayname>
32 </D:prop>
33 <D:comment>Shared workspace</D:comment>
34 <D:share-access>
35 <D:read-write />
36 </D:share-access>
37 </D:sharee>
38</D:share-resource>
39XML;
40 $request = new Request('POST', '/shareable', ['Content-Type' => 'application/davsharing+xml; charset="utf-8"'], $body);
41
42 $response = $this->request($request);
43 $this->assertEquals(200, $response->getStatus(), (string)$response->getBodyAsString());
44
45 $expected = [
46 new Sharee([
47 'href' => 'mailto:eric@example.com',
48 'properties' => [
49 '{DAV:}displayname' => 'Eric York',
50 ],
51 'access' => Plugin::ACCESS_READWRITE,
52 'comment' => 'Shared workspace',
53 'inviteStatus' => \Sabre\DAV\Sharing\Plugin::INVITE_NORESPONSE,
54 ])
55 ];
56
57 $this->assertEquals(
58 $expected,
59 $this->sharingNodeMock->getInvites()
60 );
61
62 }
63
68
69 // First we just want to execute all the actions from the first
70 // test.
71 $this->testShareResource();
72
73 $body = <<<XML
74<?xml version="1.0" encoding="utf-8" ?>
75<D:share-resource xmlns:D="DAV:">
76 <D:sharee>
77 <D:href>mailto:eric@example.com</D:href>
78 <D:share-access>
79 <D:no-access />
80 </D:share-access>
81 </D:sharee>
82</D:share-resource>
83XML;
84 $request = new Request('POST', '/shareable', ['Content-Type' => 'application/davsharing+xml; charset="utf-8"'], $body);
85
86 $response = $this->request($request);
87 $this->assertEquals(200, $response->getStatus(), (string)$response->getBodyAsString());
88
89 $expected = [];
90
91 $this->assertEquals(
92 $expected,
93 $this->sharingNodeMock->getInvites()
94 );
95
96
97 }
98
103
104 // First we just want to execute all the actions from the first
105 // test.
106 $this->testShareResource();
107
108 $body = <<<XML
109<?xml version="1.0" encoding="utf-8" ?>
110<D:propfind xmlns:D="DAV:">
111 <D:prop>
112 <D:invite />
113 <D:share-access />
114 <D:share-resource-uri />
115 </D:prop>
116</D:propfind>
117XML;
118 $request = new Request('PROPFIND', '/shareable', ['Content-Type' => 'application/xml'], $body);
119 $response = $this->request($request);
120
121 $this->assertEquals(207, $response->getStatus());
122
123 $expected = <<<XML
124<?xml version="1.0" encoding="utf-8" ?>
125<d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
126 <d:response>
127 <d:href>/shareable</d:href>
128 <d:propstat>
129 <d:prop>
130 <d:invite>
131 <d:sharee>
132 <d:href>mailto:eric@example.com</d:href>
133 <d:prop>
134 <d:displayname>Eric York</d:displayname>
135 </d:prop>
136 <d:share-access><d:read-write /></d:share-access>
137 <d:invite-noresponse />
138 </d:sharee>
139 </d:invite>
140 <d:share-access><d:shared-owner /></d:share-access>
141 <d:share-resource-uri><d:href>urn:example:bar</d:href></d:share-resource-uri>
142 </d:prop>
143 <d:status>HTTP/1.1 200 OK</d:status>
144 </d:propstat>
145 </d:response>
146</d:multistatus>
147XML;
148
149 $this->assertXmlStringEqualsXmlString($expected, $response->getBodyAsString());
150
151 }
152
154
155 $body = <<<XML
156<?xml version="1.0" encoding="utf-8" ?>
157<D:share-resource xmlns:D="DAV:">
158 <D:sharee>
159 <D:href>mailto:eric@example.com</D:href>
160 <D:prop>
161 <D:displayname>Eric York</D:displayname>
162 </D:prop>
163 <D:comment>Shared workspace</D:comment>
164 <D:share-access>
165 <D:read-write />
166 </D:share-access>
167 </D:sharee>
168</D:share-resource>
169XML;
170 $request = new Request('POST', '/not-found', ['Content-Type' => 'application/davsharing+xml; charset="utf-8"'], $body);
171
172 $response = $this->request($request, 404);
173
174 }
175
177
178 $body = <<<XML
179<?xml version="1.0" encoding="utf-8" ?>
180<D:share-resource xmlns:D="DAV:">
181 <D:sharee>
182 <D:href>mailto:eric@example.com</D:href>
183 <D:prop>
184 <D:displayname>Eric York</D:displayname>
185 </D:prop>
186 <D:comment>Shared workspace</D:comment>
187 <D:share-access>
188 <D:read-write />
189 </D:share-access>
190 </D:sharee>
191</D:share-resource>
192XML;
193 $request = new Request('POST', '/', ['Content-Type' => 'application/davsharing+xml; charset="utf-8"'], $body);
194
195 $response = $this->request($request, 403);
196
197 }
198
200
201 $body = <<<XML
202<?xml version="1.0" encoding="utf-8" ?>
203<D:blablabla xmlns:D="DAV:" />
204XML;
205 $request = new Request('POST', '/shareable', ['Content-Type' => 'application/davsharing+xml; charset="utf-8"'], $body);
206 $response = $this->request($request, 400);
207
208 }
209
210}
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.
testShareResourceRemoveAccess()
@depends testShareResource
setUpTree()
Override this to provide your own Tree for your test-case.
testShareResourceInviteProperty()
@depends testShareResource
This class represents the {DAV:}sharee element.
Definition: Sharee.php:21
The Request class represents a single HTTP request.
Definition: Request.php:18
comment()
Definition: comment.php:2
$response