Skip to content

Commit eece860

Browse files
committed
feat: return PROPFIND properties indexed by status
1 parent 985e810 commit eece860

2 files changed

Lines changed: 30 additions & 65 deletions

File tree

lib/DAV/Client.php

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -242,19 +242,11 @@ public function propFindUnfiltered($url, array $properties, $depth = 0)
242242
// If depth was 0, we only return the top item
243243
if (0 === $depth) {
244244
reset($result);
245-
$statusList = current($result);
246-
foreach ($statusList as $statusCode => $associatedProperties) {
247-
$newResult[] = ['properties' => $associatedProperties, 'status' => $statusCode];
248-
}
245+
246+
return current($result);
249247
} else {
250-
foreach ($result as $href => $statusList) {
251-
foreach ($statusList as $statusCode => $associatedProperties) {
252-
$newResult[$href][] = ['properties' => $associatedProperties, 'status' => $statusCode];
253-
}
254-
}
248+
return $result;
255249
}
256-
257-
return $newResult;
258250
}
259251

260252
/**

tests/Sabre/DAV/ClientTest.php

Lines changed: 27 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -310,18 +310,12 @@ public function testPropFindUnfilteredDepth0()
310310
$result = $client->propFindUnfiltered('folder1', ['{DAV:}resourcetype', '{DAV:}displayname', '{DAV:}contentlength', '{urn:zim}gir']);
311311

312312
self::assertEquals([
313-
[
314-
'properties' => [
315-
'{DAV:}resourcetype' => new Xml\Property\ResourceType('{DAV:}collection'),
316-
'{DAV:}displayname' => 'Folder1',
317-
],
318-
'status' => 200,
313+
200 => [
314+
'{DAV:}resourcetype' => new Xml\Property\ResourceType('{DAV:}collection'),
315+
'{DAV:}displayname' => 'Folder1',
319316
],
320-
[
321-
'properties' => [
322-
'{DAV:}contentlength' => null,
323-
],
324-
'status' => 404,
317+
404 => [
318+
'{DAV:}contentlength' => null,
325319
],
326320
], $result);
327321

@@ -424,63 +418,42 @@ public function testPropFindUnfiltered()
424418

425419
self::assertEquals([
426420
'/folder1' => [
427-
[
428-
'properties' => [
429-
'{DAV:}resourcetype' => new Xml\Property\ResourceType('{DAV:}collection'),
430-
'{DAV:}displayname' => 'Folder1',
431-
],
432-
'status' => 200,
421+
200 => [
422+
'{DAV:}resourcetype' => new Xml\Property\ResourceType('{DAV:}collection'),
423+
'{DAV:}displayname' => 'Folder1',
433424
],
434-
[
435-
'properties' => [
436-
'{DAV:}contentlength' => null,
437-
],
438-
'status' => 404,
425+
404 => [
426+
'{DAV:}contentlength' => null,
439427
],
440428
],
441429
'/folder1/file1.txt' => [
442-
[
443-
'properties' => [
444-
'{DAV:}resourcetype' => null,
445-
'{DAV:}displayname' => 'File1',
446-
'{DAV:}contentlength' => 12,
447-
],
448-
'status' => 200,
430+
200 => [
431+
'{DAV:}resourcetype' => null,
432+
'{DAV:}displayname' => 'File1',
433+
'{DAV:}contentlength' => 12,
449434
],
450435
],
451436
'/folder1/file2.txt' => [
452-
[
453-
'properties' => [
454-
'{DAV:}resourcetype' => null,
455-
'{DAV:}displayname' => 'File2',
456-
'{DAV:}contentlength' => 27,
457-
],
458-
'status' => 403,
437+
403 => [
438+
'{DAV:}resourcetype' => null,
439+
'{DAV:}displayname' => 'File2',
440+
'{DAV:}contentlength' => 27,
459441
],
460442
],
461443
'/folder1/file3.txt' => [
462-
[
463-
'properties' => [
464-
'{DAV:}resourcetype' => null,
465-
'{DAV:}displayname' => 'File3',
466-
'{DAV:}contentlength' => 42,
467-
],
468-
'status' => 425,
444+
425 => [
445+
'{DAV:}resourcetype' => null,
446+
'{DAV:}displayname' => 'File3',
447+
'{DAV:}contentlength' => 42,
469448
],
470449
],
471450
'/folder1/subfolder' => [
472-
[
473-
'properties' => [
474-
'{DAV:}resourcetype' => new Xml\Property\ResourceType('{DAV:}collection'),
475-
'{DAV:}displayname' => 'SubFolder',
476-
],
477-
'status' => 200,
451+
200 => [
452+
'{DAV:}resourcetype' => new Xml\Property\ResourceType('{DAV:}collection'),
453+
'{DAV:}displayname' => 'SubFolder',
478454
],
479-
[
480-
'properties' => [
481-
'{DAV:}contentlength' => null,
482-
],
483-
'status' => 404,
455+
404 => [
456+
'{DAV:}contentlength' => null,
484457
],
485458
],
486459
], $result);

0 commit comments

Comments
 (0)