8 require_once __DIR__ .
'/MockSyncCollection.php';
17 $this->server->addPlugin(
new Plugin());
23 $this->assertArrayHasKey(
25 (
new Plugin())->getPluginInfo()
46 $result = $this->server->getProperties(
'/coll', [
'{DAV:}supported-report-set']);
47 $this->assertFalse(
$result[
'{DAV:}supported-report-set']->has(
'{DAV:}sync-collection'));
50 $this->collection->addChange([
'file1.txt'], [], []);
52 $result = $this->server->getProperties(
'/coll', [
'{DAV:}supported-report-set']);
53 $this->assertTrue(
$result[
'{DAV:}supported-report-set']->has(
'{DAV:}sync-collection'));
59 $result = $this->server->getProperties(
'/coll', [
'{DAV:}sync-token']);
60 $this->assertFalse(isset(
$result[
'{DAV:}sync-token']));
63 $this->collection->addChange([
'file1.txt'], [], []);
65 $result = $this->server->getProperties(
'/coll', [
'{DAV:}sync-token']);
66 $this->assertTrue(isset(
$result[
'{DAV:}sync-token']));
69 $this->collection->addChange([
'file1.txt'], [], []);
71 $result = $this->server->getProperties(
'/normalcoll', [
'{DAV:}sync-token']);
72 $this->assertFalse(isset(
$result[
'{DAV:}sync-token']));
78 $this->collection->addChange([
'file1.txt'], [], []);
80 $request =
new HTTP\Request(
'REPORT',
'/coll/', [
'Content-Type' =>
'application/xml']);
83 <?xml version=
"1.0" encoding=
"utf-8" ?>
84 <
D:sync-collection xmlns:
D=
"DAV:">
86 <
D:sync-level>1</
D:sync-level>
99 $multiStatus = $this->server->xml->parse(
$response->getBodyAsString());
103 'http://sabre.io/ns/sync/1',
104 $multiStatus->getSyncToken()
107 $responses = $multiStatus->getResponses();
108 $this->assertEquals(2, count($responses),
'We expected exactly 2 {DAV:}response');
112 $this->assertNull(
$response->getHttpStatus());
113 $this->assertEquals(
'/coll/file1.txt',
$response->getHref());
114 $this->assertEquals([
116 '{DAV:}getcontentlength' => 3,
122 $this->assertNull($response->getHttpStatus());
123 $this->assertEquals(
'/coll/file2.txt', $response->getHref());
124 $this->assertEquals([
126 '{DAV:}getcontentlength' => 3,
128 ], $response->getResponseProperties());
135 $this->collection->addChange([
'file1.txt'], [], []);
137 $this->collection->addChange([], [
'file2.txt'], [
'file3.txt']);
140 'REQUEST_METHOD' =>
'REPORT',
141 'REQUEST_URI' =>
'/coll/',
142 'CONTENT_TYPE' =>
'application/xml',
146 <?xml version=
"1.0" encoding=
"utf-8" ?>
147 <
D:sync-collection xmlns:
D=
"DAV:">
149 <
D:sync-level>infinite</
D:sync-level>
151 <
D:getcontentlength/>
162 $multiStatus = $this->server->xml->parse(
$response->getBodyAsString());
166 'http://sabre.io/ns/sync/2',
167 $multiStatus->getSyncToken()
170 $responses = $multiStatus->getResponses();
171 $this->assertEquals(2, count($responses),
'We expected exactly 2 {DAV:}response');
175 $this->assertNull(
$response->getHttpStatus());
176 $this->assertEquals(
'/coll/file2.txt',
$response->getHref());
177 $this->assertEquals([
179 '{DAV:}getcontentlength' => 3,
185 $this->assertEquals(
'404', $response->getHttpStatus());
186 $this->assertEquals(
'/coll/file3.txt', $response->getHref());
187 $this->assertEquals([], $response->getResponseProperties());
194 $this->collection->addChange([
'file1.txt'], [], []);
196 $this->collection->addChange([], [
'file2.txt'], [
'file3.txt']);
199 'REQUEST_METHOD' =>
'REPORT',
200 'REQUEST_URI' =>
'/coll/',
201 'CONTENT_TYPE' =>
'application/xml',
205 <?xml version=
"1.0" encoding=
"utf-8" ?>
206 <
D:sync-collection xmlns:
D=
"DAV:">
208 <
D:sync-level>infinite</
D:sync-level>
210 <
D:getcontentlength/>
212 <
D:limit><
D:nresults>1</
D:nresults></
D:limit>
222 $multiStatus = $this->server->xml->parse(
228 'http://sabre.io/ns/sync/2',
229 $multiStatus->getSyncToken()
232 $responses = $multiStatus->getResponses();
233 $this->assertEquals(1, count($responses),
'We expected exactly 1 {DAV:}response');
237 $this->assertEquals(
'404',
$response->getHttpStatus());
238 $this->assertEquals(
'/coll/file3.txt',
$response->getHref());
239 $this->assertEquals([],
$response->getResponseProperties());
246 $this->collection->addChange([
'file1.txt'], [], []);
248 $this->collection->addChange([], [
'file2.txt'], [
'file3.txt']);
251 'REQUEST_METHOD' =>
'REPORT',
252 'REQUEST_URI' =>
'/coll/',
253 'CONTENT_TYPE' =>
'application/xml',
258 <?xml version=
"1.0" encoding=
"utf-8" ?>
259 <
D:sync-collection xmlns:
D=
"DAV:">
262 <
D:getcontentlength/>
273 $multiStatus = $this->server->xml->parse(
279 'http://sabre.io/ns/sync/2',
280 $multiStatus->getSyncToken()
283 $responses = $multiStatus->getResponses();
284 $this->assertEquals(2, count($responses),
'We expected exactly 2 {DAV:}response');
288 $this->assertNull(
$response->getHttpStatus());
289 $this->assertEquals(
'/coll/file2.txt',
$response->getHref());
290 $this->assertEquals([
292 '{DAV:}getcontentlength' => 3,
298 $this->assertEquals(
'404', $response->getHttpStatus());
299 $this->assertEquals(
'/coll/file3.txt', $response->getHref());
300 $this->assertEquals([], $response->getResponseProperties());
307 'REQUEST_METHOD' =>
'REPORT',
308 'REQUEST_URI' =>
'/coll/',
309 'CONTENT_TYPE' =>
'application/xml',
313 <?xml version=
"1.0" encoding=
"utf-8" ?>
314 <
D:sync-collection xmlns:
D=
"DAV:">
316 <
D:sync-level>1</
D:sync-level>
318 <
D:getcontentlength/>
336 'REQUEST_METHOD' =>
'REPORT',
337 'REQUEST_URI' =>
'/normalcoll/',
338 'CONTENT_TYPE' =>
'application/xml',
342 <?xml version=
"1.0" encoding=
"utf-8" ?>
343 <
D:sync-collection xmlns:
D=
"DAV:">
345 <
D:sync-level>1</
D:sync-level>
347 <
D:getcontentlength/>
364 $this->collection->addChange([
'file1.txt'], [], []);
366 'REQUEST_METHOD' =>
'REPORT',
367 'REQUEST_URI' =>
'/coll/',
368 'CONTENT_TYPE' =>
'application/xml',
372 <?xml version=
"1.0" encoding=
"utf-8" ?>
373 <
D:sync-collection xmlns:
D=
"DAV:">
375 <
D:sync-level>1</
D:sync-level>
377 <
D:getcontentlength/>
393 $this->collection->addChange([
'file1.txt'], [], []);
395 'REQUEST_METHOD' =>
'REPORT',
396 'REQUEST_URI' =>
'/coll/',
397 'CONTENT_TYPE' =>
'application/xml',
401 <?xml version=
"1.0" encoding=
"utf-8" ?>
402 <
D:sync-collection xmlns:
D=
"DAV:">
403 <
D:sync-token>invalid</
D:sync-token>
404 <
D:sync-level>1</
D:sync-level>
406 <
D:getcontentlength/>
424 'REQUEST_METHOD' =>
'REPORT',
425 'REQUEST_URI' =>
'/coll/',
426 'CONTENT_TYPE' =>
'application/xml',
430 <?xml version=
"1.0" encoding=
"utf-8" ?>
431 <
D:sync-collection xmlns:
D=
"DAV:">
432 <
D:sync-level>1</
D:sync-level>
434 <
D:getcontentlength/>
451 $this->collection->addChange([
'file1.txt'], [], []);
453 'REQUEST_METHOD' =>
'REPORT',
454 'REQUEST_URI' =>
'/coll/',
455 'CONTENT_TYPE' =>
'application/xml',
459 <?xml version=
"1.0" encoding=
"utf-8" ?>
460 <
D:sync-collection xmlns:
D=
"DAV:">
462 <
D:sync-level>1</
D:sync-level>
478 $this->collection->addChange([
'file1.txt'], [], []);
480 'REQUEST_METHOD' =>
'DELETE',
481 'REQUEST_URI' =>
'/coll/file1.txt',
482 'HTTP_IF' =>
'</coll> (<http://sabre.io/ns/sync/1>)',
489 $this->assertEquals(403,
$response->status);
495 $this->collection->addChange([
'file1.txt'], [], []);
497 'REQUEST_METHOD' =>
'DELETE',
498 'REQUEST_URI' =>
'/coll/file1.txt',
499 'HTTP_IF' =>
'</coll> (Not <http://sabre.io/ns/sync/2>)',
506 $this->assertEquals(403,
$response->status);
512 $this->collection->addChange([
'file1.txt'], [], []);
514 'REQUEST_METHOD' =>
'DELETE',
515 'REQUEST_URI' =>
'/coll/file1.txt',
516 'HTTP_IF' =>
'</coll> (<opaquelocktoken:foo>)',
520 $this->assertEquals(412,
$response->status);
testSubsequentSyncSyncCollection()
foreach($paths as $path) $request
This plugin all WebDAV-sync capabilities to the Server.
This mocks a ISyncCollection, for unittesting.
static http()
Fetches the global http state from ILIAS.
testSubsequentSyncSyncCollectionLimit()
This class may be used as a basis for other webdav-related unittests.
testSubsequentSyncSyncCollectionDepthFallBack()
testSyncInvalidTokenNoPrefix()
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.
testSyncInitialSyncCollection()
testIfConditionsNoSyncToken()
testSyncNoSyncCollection()