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

Public Member Functions

 setUp ()
 
 testConstruct ()
 
 testConstructNoBaseUri ()
 @expectedException InvalidArgumentException More...
 
 testAuth ()
 
 testBasicAuth ()
 
 testDigestAuth ()
 
 testNTLMAuth ()
 
 testProxy ()
 
 testEncoding ()
 
 testPropFind ()
 
 testPropFindError ()
 @expectedException \Sabre\HTTP\ClientHttpException More...
 
 testPropFindDepth1 ()
 
 testPropPatch ()
 
 testPropPatchHTTPError ()
 @depends testPropPatch @expectedException \Sabre\HTTP\ClientHttpException More...
 
 testPropPatchMultiStatusError ()
 @depends testPropPatch @expectedException Sabre\HTTP\ClientException More...
 
 testOPTIONS ()
 

Detailed Description

Definition at line 10 of file ClientTest.php.

Member Function Documentation

◆ setUp()

Sabre\DAV\ClientTest::setUp ( )

Definition at line 12 of file ClientTest.php.

12 {
13
14 if (!function_exists('curl_init')) {
15 $this->markTestSkipped('CURL must be installed to test the client');
16 }
17
18 }

◆ testAuth()

Sabre\DAV\ClientTest::testAuth ( )

Definition at line 38 of file ClientTest.php.

38 {
39
40 $client = new ClientMock([
41 'baseUri' => '/',
42 'userName' => 'foo',
43 'password' => 'bar',
44 ]);
45
46 $this->assertEquals("foo:bar", $client->curlSettings[CURLOPT_USERPWD]);
47 $this->assertEquals(CURLAUTH_BASIC | CURLAUTH_DIGEST, $client->curlSettings[CURLOPT_HTTPAUTH]);
48
49 }
if($_SERVER['argc']< 4) $client
Definition: cron.php:12

References $client.

◆ testBasicAuth()

Sabre\DAV\ClientTest::testBasicAuth ( )

Definition at line 51 of file ClientTest.php.

51 {
52
53 $client = new ClientMock([
54 'baseUri' => '/',
55 'userName' => 'foo',
56 'password' => 'bar',
57 'authType' => Client::AUTH_BASIC
58 ]);
59
60 $this->assertEquals("foo:bar", $client->curlSettings[CURLOPT_USERPWD]);
61 $this->assertEquals(CURLAUTH_BASIC, $client->curlSettings[CURLOPT_HTTPAUTH]);
62
63 }
const AUTH_BASIC
Basic authentication.
Definition: Client.php:54

References $client, and Sabre\DAV\Client\AUTH_BASIC.

◆ testConstruct()

Sabre\DAV\ClientTest::testConstruct ( )

Definition at line 20 of file ClientTest.php.

20 {
21
22 $client = new ClientMock([
23 'baseUri' => '/',
24 ]);
25 $this->assertInstanceOf('Sabre\DAV\ClientMock', $client);
26
27 }

References $client.

◆ testConstructNoBaseUri()

Sabre\DAV\ClientTest::testConstructNoBaseUri ( )

@expectedException InvalidArgumentException

Definition at line 32 of file ClientTest.php.

32 {
33
34 $client = new ClientMock([]);
35
36 }

References $client.

◆ testDigestAuth()

Sabre\DAV\ClientTest::testDigestAuth ( )

Definition at line 65 of file ClientTest.php.

65 {
66
67 $client = new ClientMock([
68 'baseUri' => '/',
69 'userName' => 'foo',
70 'password' => 'bar',
71 'authType' => Client::AUTH_DIGEST
72 ]);
73
74 $this->assertEquals("foo:bar", $client->curlSettings[CURLOPT_USERPWD]);
75 $this->assertEquals(CURLAUTH_DIGEST, $client->curlSettings[CURLOPT_HTTPAUTH]);
76
77 }
const AUTH_DIGEST
Digest authentication.
Definition: Client.php:59

References $client, and Sabre\DAV\Client\AUTH_DIGEST.

◆ testEncoding()

Sabre\DAV\ClientTest::testEncoding ( )

Definition at line 104 of file ClientTest.php.

104 {
105
106 $client = new ClientMock([
107 'baseUri' => '/',
109 ]);
110
111 $this->assertEquals("identity,deflate,gzip", $client->curlSettings[CURLOPT_ENCODING]);
112
113 }
const ENCODING_DEFLATE
Deflate encoding.
Definition: Client.php:74
const ENCODING_IDENTITY
Identity encoding, which basically does not nothing.
Definition: Client.php:69
const ENCODING_GZIP
Gzip encoding.
Definition: Client.php:79

References $client, Sabre\DAV\Client\ENCODING_DEFLATE, Sabre\DAV\Client\ENCODING_GZIP, and Sabre\DAV\Client\ENCODING_IDENTITY.

◆ testNTLMAuth()

Sabre\DAV\ClientTest::testNTLMAuth ( )

Definition at line 79 of file ClientTest.php.

79 {
80
81 $client = new ClientMock([
82 'baseUri' => '/',
83 'userName' => 'foo',
84 'password' => 'bar',
85 'authType' => Client::AUTH_NTLM
86 ]);
87
88 $this->assertEquals("foo:bar", $client->curlSettings[CURLOPT_USERPWD]);
89 $this->assertEquals(CURLAUTH_NTLM, $client->curlSettings[CURLOPT_HTTPAUTH]);
90
91 }
const AUTH_NTLM
NTLM authentication.
Definition: Client.php:64

References $client, and Sabre\DAV\Client\AUTH_NTLM.

◆ testOPTIONS()

Sabre\DAV\ClientTest::testOPTIONS ( )

Definition at line 283 of file ClientTest.php.

283 {
284
285 $client = new ClientMock([
286 'baseUri' => '/',
287 ]);
288
289 $client->response = new Response(207, [
290 'DAV' => 'calendar-access, extended-mkcol',
291 ]);
292 $result = $client->options();
293
294 $this->assertEquals(
295 ['calendar-access', 'extended-mkcol'],
296 $result
297 );
298
299 $request = $client->request;
300 $this->assertEquals('OPTIONS', $request->getMethod());
301 $this->assertEquals('/', $request->getUrl());
302 $this->assertEquals([
303 ], $request->getHeaders());
304
305 }
$result
foreach($paths as $path) $request
Definition: asyncclient.php:32

References $client, $request, and $result.

◆ testPropFind()

Sabre\DAV\ClientTest::testPropFind ( )

Definition at line 115 of file ClientTest.php.

115 {
116
117 $client = new ClientMock([
118 'baseUri' => '/',
119 ]);
120
121 $responseBody = <<<XML
122<?xml version="1.0"?>
123<multistatus xmlns="DAV:">
124 <response>
125 <href>/foo</href>
126 <propstat>
127 <prop>
128 <displayname>bar</displayname>
129 </prop>
130 <status>HTTP/1.1 200 OK</status>
131 </propstat>
132 </response>
133</multistatus>
134XML;
135
136 $client->response = new Response(207, [], $responseBody);
137 $result = $client->propFind('foo', ['{DAV:}displayname', '{urn:zim}gir']);
138
139 $this->assertEquals(['{DAV:}displayname' => 'bar'], $result);
140
141 $request = $client->request;
142 $this->assertEquals('PROPFIND', $request->getMethod());
143 $this->assertEquals('/foo', $request->getUrl());
144 $this->assertEquals([
145 'Depth' => ['0'],
146 'Content-Type' => ['application/xml'],
147 ], $request->getHeaders());
148
149 }

References $client, $request, and $result.

◆ testPropFindDepth1()

Sabre\DAV\ClientTest::testPropFindDepth1 ( )

Definition at line 165 of file ClientTest.php.

165 {
166
167 $client = new ClientMock([
168 'baseUri' => '/',
169 ]);
170
171 $responseBody = <<<XML
172<?xml version="1.0"?>
173<multistatus xmlns="DAV:">
174 <response>
175 <href>/foo</href>
176 <propstat>
177 <prop>
178 <displayname>bar</displayname>
179 </prop>
180 <status>HTTP/1.1 200 OK</status>
181 </propstat>
182 </response>
183</multistatus>
184XML;
185
186 $client->response = new Response(207, [], $responseBody);
187 $result = $client->propFind('foo', ['{DAV:}displayname', '{urn:zim}gir'], 1);
188
189 $this->assertEquals([
190 '/foo' => [
191 '{DAV:}displayname' => 'bar'
192 ],
193 ], $result);
194
195 $request = $client->request;
196 $this->assertEquals('PROPFIND', $request->getMethod());
197 $this->assertEquals('/foo', $request->getUrl());
198 $this->assertEquals([
199 'Depth' => ['1'],
200 'Content-Type' => ['application/xml'],
201 ], $request->getHeaders());
202
203 }

References $client, $request, and $result.

◆ testPropFindError()

Sabre\DAV\ClientTest::testPropFindError ( )

@expectedException \Sabre\HTTP\ClientHttpException

Definition at line 154 of file ClientTest.php.

154 {
155
156 $client = new ClientMock([
157 'baseUri' => '/',
158 ]);
159
160 $client->response = new Response(405, []);
161 $client->propFind('foo', ['{DAV:}displayname', '{urn:zim}gir']);
162
163 }

References $client.

◆ testPropPatch()

Sabre\DAV\ClientTest::testPropPatch ( )

Definition at line 205 of file ClientTest.php.

205 {
206
207 $client = new ClientMock([
208 'baseUri' => '/',
209 ]);
210
211 $responseBody = <<<XML
212<?xml version="1.0"?>
213<multistatus xmlns="DAV:">
214 <response>
215 <href>/foo</href>
216 <propstat>
217 <prop>
218 <displayname>bar</displayname>
219 </prop>
220 <status>HTTP/1.1 200 OK</status>
221 </propstat>
222 </response>
223</multistatus>
224XML;
225
226 $client->response = new Response(207, [], $responseBody);
227 $result = $client->propPatch('foo', ['{DAV:}displayname' => 'hi', '{urn:zim}gir' => null]);
228 $this->assertTrue($result);
229 $request = $client->request;
230 $this->assertEquals('PROPPATCH', $request->getMethod());
231 $this->assertEquals('/foo', $request->getUrl());
232 $this->assertEquals([
233 'Content-Type' => ['application/xml'],
234 ], $request->getHeaders());
235
236 }

References $client, $request, and $result.

◆ testPropPatchHTTPError()

Sabre\DAV\ClientTest::testPropPatchHTTPError ( )

@depends testPropPatch @expectedException \Sabre\HTTP\ClientHttpException

Definition at line 242 of file ClientTest.php.

242 {
243
244 $client = new ClientMock([
245 'baseUri' => '/',
246 ]);
247
248 $client->response = new Response(403, [], '');
249 $client->propPatch('foo', ['{DAV:}displayname' => 'hi', '{urn:zim}gir' => null]);
250
251 }

References $client.

◆ testPropPatchMultiStatusError()

Sabre\DAV\ClientTest::testPropPatchMultiStatusError ( )

@depends testPropPatch @expectedException Sabre\HTTP\ClientException

Definition at line 257 of file ClientTest.php.

257 {
258
259 $client = new ClientMock([
260 'baseUri' => '/',
261 ]);
262
263 $responseBody = <<<XML
264<?xml version="1.0"?>
265<multistatus xmlns="DAV:">
266<response>
267 <href>/foo</href>
268 <propstat>
269 <prop>
270 <displayname />
271 </prop>
272 <status>HTTP/1.1 403 Forbidden</status>
273 </propstat>
274</response>
275</multistatus>
276XML;
277
278 $client->response = new Response(207, [], $responseBody);
279 $client->propPatch('foo', ['{DAV:}displayname' => 'hi', '{urn:zim}gir' => null]);
280
281 }

References $client.

◆ testProxy()

Sabre\DAV\ClientTest::testProxy ( )

Definition at line 93 of file ClientTest.php.

93 {
94
95 $client = new ClientMock([
96 'baseUri' => '/',
97 'proxy' => 'localhost:8888',
98 ]);
99
100 $this->assertEquals("localhost:8888", $client->curlSettings[CURLOPT_PROXY]);
101
102 }

References $client.


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