ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ServerUpdatePropertiesTest.php
Go to the documentation of this file.
1<?php
2
3namespace Sabre\DAV;
4
6
8
9 $tree = [
10 new SimpleCollection('foo'),
11 ];
12 $server = new Server($tree);
13
14 $result = $server->updateProperties('foo', [
15 '{DAV:}foo' => 'bar'
16 ]);
17
18 $expected = [
19 '{DAV:}foo' => 403,
20 ];
21 $this->assertEquals($expected, $result);
22
23 }
24
26
27 $tree = [
28 new SimpleCollection('foo'),
29 ];
30 $server = new Server($tree);
31
32 $server->on('propPatch', function($path, PropPatch $propPatch) {
33 $propPatch->handleRemaining(function() { return true; });
34 });
35 $result = $server->updateProperties('foo', [
36 '{DAV:}getetag' => 'bla',
37 '{DAV:}foo' => 'bar'
38 ]);
39
40 $expected = [
41 '{DAV:}getetag' => 403,
42 '{DAV:}foo' => 424,
43 ];
44 $this->assertEquals($expected, $result);
45
46 }
47
49
50 $tree = [
51 new SimpleCollection('foo'),
52 ];
53 $server = new Server($tree);
54 $server->on('propPatch', function($path, PropPatch $propPatch) {
55 $propPatch->setResultCode('{DAV:}foo', 404);
56 $propPatch->handleRemaining(function() { return true; });
57 });
58
59 $result = $server->updateProperties('foo', [
60 '{DAV:}foo' => 'bar',
61 '{DAV:}foo2' => 'bla',
62 ]);
63
64 $expected = [
65 '{DAV:}foo' => 404,
66 '{DAV:}foo2' => 424,
67 ];
68 $this->assertEquals($expected, $result);
69
70 }
71
73
74 $tree = [
75 new SimpleCollection('foo'),
76 ];
77 $server = new Server($tree);
78 $server->on('propPatch', function($path, PropPatch $propPatch) {
79
80 $propPatch->handle(['{DAV:}foo', '{DAV:}foo2'], function() {
81 return [
82 '{DAV:}foo' => 200,
83 '{DAV:}foo2' => 201,
84 ];
85 });
86
87 });
88
89 $result = $server->updateProperties('foo', [
90 '{DAV:}foo' => 'bar',
91 '{DAV:}foo2' => 'bla',
92 ]);
93
94 $expected = [
95 '{DAV:}foo' => 200,
96 '{DAV:}foo2' => 201,
97 ];
98 $this->assertEquals($expected, $result);
99
100 }
101
102}
$result
$path
Definition: aliased.php:25
An exception for terminatinating execution or to throw for unit testing.
This class represents a set of properties that are going to be updated.
Definition: PropPatch.php:20
handle($properties, callable $callback)
Call this function if you wish to handle updating certain properties.
Definition: PropPatch.php:87
setResultCode($properties, $resultCode)
Sets the result code for one or more properties.
Definition: PropPatch.php:150
handleRemaining(callable $callback)
Call this function if you wish to handle all properties that haven't been handled by anything else ye...
Definition: PropPatch.php:123
Main DAV server class.
Definition: Server.php:23
$server
Definition: sabredav.php:48