]> git.mxchange.org Git - friendica-addons.git/blob - dav/SabreDAV/tests/Sabre/DAV/ServerUpdatePropertiesTest.php
Merge branch 'master' of git://github.com/friendica/friendica-addons
[friendica-addons.git] / dav / SabreDAV / tests / Sabre / DAV / ServerUpdatePropertiesTest.php
1 <?php
2
3 class Sabre_DAV_ServerUpdatePropertiesTest extends PHPUnit_Framework_TestCase {
4
5     function testUpdatePropertiesFail() {
6
7         $tree = array(
8             new Sabre_DAV_SimpleCollection('foo'),
9         );
10         $server = new Sabre_DAV_Server($tree);
11
12         $result = $server->updateProperties('foo', array(
13             '{DAV:}foo' => 'bar'
14         ));
15
16         $expected = array(
17             'href' => 'foo',
18             '403' => array(
19                 '{DAV:}foo' => null,
20             ),
21         );
22         $this->assertEquals($expected, $result);
23
24     }
25
26     function testUpdatePropertiesProtected() {
27
28         $tree = array(
29             new Sabre_DAV_SimpleCollection('foo'),
30         );
31         $server = new Sabre_DAV_Server($tree);
32
33         $result = $server->updateProperties('foo', array(
34             '{DAV:}getetag' => 'bla',
35             '{DAV:}foo' => 'bar'
36         ));
37
38         $expected = array(
39             'href' => 'foo',
40             '403' => array(
41                 '{DAV:}getetag' => null,
42             ),
43             '424' => array(
44                 '{DAV:}foo' => null,
45             ),
46         );
47         $this->assertEquals($expected, $result);
48
49     }
50
51     function testUpdatePropertiesEventFail() {
52
53         $tree = array(
54             new Sabre_DAV_SimpleCollection('foo'),
55         );
56         $server = new Sabre_DAV_Server($tree);
57         $server->subscribeEvent('updateProperties', array($this,'updatepropfail'));
58
59         $result = $server->updateProperties('foo', array(
60             '{DAV:}foo' => 'bar',
61             '{DAV:}foo2' => 'bla',
62         ));
63
64         $expected = array(
65             'href' => 'foo',
66             '404' => array(
67                 '{DAV:}foo' => null,
68             ),
69             '424' => array(
70                 '{DAV:}foo2' => null,
71             ),
72         );
73         $this->assertEquals($expected, $result);
74
75     }
76
77     function updatePropFail(&$propertyDelta, &$result, $node) {
78
79         $result[404] = array(
80             '{DAV:}foo' => null,
81         );
82         unset($propertyDelta['{DAV:}foo']);
83         return false;
84
85     }
86
87
88     function testUpdatePropertiesEventSuccess() {
89
90         $tree = array(
91             new Sabre_DAV_SimpleCollection('foo'),
92         );
93         $server = new Sabre_DAV_Server($tree);
94         $server->subscribeEvent('updateProperties', array($this,'updatepropsuccess'));
95
96         $result = $server->updateProperties('foo', array(
97             '{DAV:}foo' => 'bar',
98             '{DAV:}foo2' => 'bla',
99         ));
100
101         $expected = array(
102             'href' => 'foo',
103             '200' => array(
104                 '{DAV:}foo' => null,
105             ),
106             '201' => array(
107                 '{DAV:}foo2' => null,
108             ),
109         );
110         $this->assertEquals($expected, $result);
111
112     }
113
114     function updatePropSuccess(&$propertyDelta, &$result, $node) {
115
116         $result[200] = array(
117             '{DAV:}foo' => null,
118         );
119         $result[201] = array(
120             '{DAV:}foo2' => null,
121         );
122         unset($propertyDelta['{DAV:}foo']);
123         unset($propertyDelta['{DAV:}foo2']);
124         return;
125
126     }
127 }