xref: /plugin/davcal/vendor/sabre/dav/tests/Sabre/DAVACL/PluginPropertiesTest.php (revision a1a3b6794e0e143a4a8b51d3185ce2d339be61ab)
1*a1a3b679SAndreas Boehler<?php
2*a1a3b679SAndreas Boehler
3*a1a3b679SAndreas Boehlernamespace Sabre\DAVACL;
4*a1a3b679SAndreas Boehler
5*a1a3b679SAndreas Boehleruse Sabre\DAV;
6*a1a3b679SAndreas Boehleruse Sabre\HTTP;
7*a1a3b679SAndreas Boehler
8*a1a3b679SAndreas Boehlerclass PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
9*a1a3b679SAndreas Boehler
10*a1a3b679SAndreas Boehler    function testPrincipalCollectionSet() {
11*a1a3b679SAndreas Boehler
12*a1a3b679SAndreas Boehler        $plugin = new Plugin();
13*a1a3b679SAndreas Boehler        $plugin->principalCollectionSet = [
14*a1a3b679SAndreas Boehler            'principals1',
15*a1a3b679SAndreas Boehler            'principals2',
16*a1a3b679SAndreas Boehler        ];
17*a1a3b679SAndreas Boehler
18*a1a3b679SAndreas Boehler        $requestedProperties = [
19*a1a3b679SAndreas Boehler            '{DAV:}principal-collection-set',
20*a1a3b679SAndreas Boehler        ];
21*a1a3b679SAndreas Boehler
22*a1a3b679SAndreas Boehler        $server = new DAV\Server(new DAV\SimpleCollection('root'));
23*a1a3b679SAndreas Boehler        $server->addPlugin($plugin);
24*a1a3b679SAndreas Boehler
25*a1a3b679SAndreas Boehler        $result = $server->getPropertiesForPath('', $requestedProperties);
26*a1a3b679SAndreas Boehler        $result = $result[0];
27*a1a3b679SAndreas Boehler
28*a1a3b679SAndreas Boehler        $this->assertEquals(1,count($result[200]));
29*a1a3b679SAndreas Boehler        $this->assertArrayHasKey('{DAV:}principal-collection-set',$result[200]);
30*a1a3b679SAndreas Boehler        $this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $result[200]['{DAV:}principal-collection-set']);
31*a1a3b679SAndreas Boehler
32*a1a3b679SAndreas Boehler        $expected = [
33*a1a3b679SAndreas Boehler            'principals1/',
34*a1a3b679SAndreas Boehler            'principals2/',
35*a1a3b679SAndreas Boehler        ];
36*a1a3b679SAndreas Boehler
37*a1a3b679SAndreas Boehler
38*a1a3b679SAndreas Boehler        $this->assertEquals($expected, $result[200]['{DAV:}principal-collection-set']->getHrefs());
39*a1a3b679SAndreas Boehler
40*a1a3b679SAndreas Boehler
41*a1a3b679SAndreas Boehler    }
42*a1a3b679SAndreas Boehler
43*a1a3b679SAndreas Boehler    function testCurrentUserPrincipal() {
44*a1a3b679SAndreas Boehler
45*a1a3b679SAndreas Boehler        $fakeServer = new DAV\Server();
46*a1a3b679SAndreas Boehler        $plugin = new DAV\Auth\Plugin(new DAV\Auth\Backend\Mock(),'realm');
47*a1a3b679SAndreas Boehler        $fakeServer->addPlugin($plugin);
48*a1a3b679SAndreas Boehler        $plugin = new Plugin();
49*a1a3b679SAndreas Boehler        $fakeServer->addPlugin($plugin);
50*a1a3b679SAndreas Boehler
51*a1a3b679SAndreas Boehler
52*a1a3b679SAndreas Boehler        $requestedProperties = [
53*a1a3b679SAndreas Boehler            '{DAV:}current-user-principal',
54*a1a3b679SAndreas Boehler        ];
55*a1a3b679SAndreas Boehler
56*a1a3b679SAndreas Boehler        $result = $fakeServer->getPropertiesForPath('', $requestedProperties);
57*a1a3b679SAndreas Boehler        $result = $result[0];
58*a1a3b679SAndreas Boehler
59*a1a3b679SAndreas Boehler        $this->assertEquals(1,count($result[200]));
60*a1a3b679SAndreas Boehler        $this->assertArrayHasKey('{DAV:}current-user-principal',$result[200]);
61*a1a3b679SAndreas Boehler        $this->assertInstanceOf('Sabre\DAVACL\Xml\Property\Principal', $result[200]['{DAV:}current-user-principal']);
62*a1a3b679SAndreas Boehler        $this->assertEquals(Xml\Property\Principal::UNAUTHENTICATED, $result[200]['{DAV:}current-user-principal']->getType());
63*a1a3b679SAndreas Boehler
64*a1a3b679SAndreas Boehler        // This will force the login
65*a1a3b679SAndreas Boehler        $fakeServer->emit('beforeMethod', [$fakeServer->httpRequest, $fakeServer->httpResponse]);
66*a1a3b679SAndreas Boehler
67*a1a3b679SAndreas Boehler        $result = $fakeServer->getPropertiesForPath('', $requestedProperties);
68*a1a3b679SAndreas Boehler        $result = $result[0];
69*a1a3b679SAndreas Boehler
70*a1a3b679SAndreas Boehler        $this->assertEquals(1,count($result[200]));
71*a1a3b679SAndreas Boehler        $this->assertArrayHasKey('{DAV:}current-user-principal',$result[200]);
72*a1a3b679SAndreas Boehler        $this->assertInstanceOf('Sabre\DAVACL\Xml\Property\Principal', $result[200]['{DAV:}current-user-principal']);
73*a1a3b679SAndreas Boehler        $this->assertEquals(Xml\Property\Principal::HREF, $result[200]['{DAV:}current-user-principal']->getType());
74*a1a3b679SAndreas Boehler        $this->assertEquals('principals/admin/', $result[200]['{DAV:}current-user-principal']->getHref());
75*a1a3b679SAndreas Boehler
76*a1a3b679SAndreas Boehler    }
77*a1a3b679SAndreas Boehler
78*a1a3b679SAndreas Boehler    function testSupportedPrivilegeSet() {
79*a1a3b679SAndreas Boehler
80*a1a3b679SAndreas Boehler        $plugin = new Plugin();
81*a1a3b679SAndreas Boehler        $server = new DAV\Server();
82*a1a3b679SAndreas Boehler        $server->addPlugin($plugin);
83*a1a3b679SAndreas Boehler
84*a1a3b679SAndreas Boehler        $requestedProperties = [
85*a1a3b679SAndreas Boehler            '{DAV:}supported-privilege-set',
86*a1a3b679SAndreas Boehler        ];
87*a1a3b679SAndreas Boehler
88*a1a3b679SAndreas Boehler        $result = $server->getPropertiesForPath('', $requestedProperties);
89*a1a3b679SAndreas Boehler        $result = $result[0];
90*a1a3b679SAndreas Boehler
91*a1a3b679SAndreas Boehler        $this->assertEquals(1,count($result[200]));
92*a1a3b679SAndreas Boehler        $this->assertArrayHasKey('{DAV:}supported-privilege-set',$result[200]);
93*a1a3b679SAndreas Boehler        $this->assertInstanceOf('Sabre\\DAVACL\\Xml\\Property\\SupportedPrivilegeSet', $result[200]['{DAV:}supported-privilege-set']);
94*a1a3b679SAndreas Boehler
95*a1a3b679SAndreas Boehler        $server = new DAV\Server();
96*a1a3b679SAndreas Boehler
97*a1a3b679SAndreas Boehler        $prop = $result[200]['{DAV:}supported-privilege-set'];
98*a1a3b679SAndreas Boehler        $result = $server->xml->write('{DAV:}root', $prop);
99*a1a3b679SAndreas Boehler
100*a1a3b679SAndreas Boehler        $xpaths = [
101*a1a3b679SAndreas Boehler            '/d:root' => 1,
102*a1a3b679SAndreas Boehler            '/d:root/d:supported-privilege' => 1,
103*a1a3b679SAndreas Boehler            '/d:root/d:supported-privilege/d:privilege' => 1,
104*a1a3b679SAndreas Boehler            '/d:root/d:supported-privilege/d:privilege/d:all' => 1,
105*a1a3b679SAndreas Boehler            '/d:root/d:supported-privilege/d:abstract' => 1,
106*a1a3b679SAndreas Boehler            '/d:root/d:supported-privilege/d:supported-privilege' => 2,
107*a1a3b679SAndreas Boehler            '/d:root/d:supported-privilege/d:supported-privilege/d:privilege' => 2,
108*a1a3b679SAndreas Boehler            '/d:root/d:supported-privilege/d:supported-privilege/d:privilege/d:read' => 1,
109*a1a3b679SAndreas Boehler            '/d:root/d:supported-privilege/d:supported-privilege/d:privilege/d:write' => 1,
110*a1a3b679SAndreas Boehler            '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege' => 8,
111*a1a3b679SAndreas Boehler            '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege' => 8,
112*a1a3b679SAndreas Boehler            '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:read-acl' => 1,
113*a1a3b679SAndreas Boehler            '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:read-current-user-privilege-set' => 1,
114*a1a3b679SAndreas Boehler            '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:write-content' => 1,
115*a1a3b679SAndreas Boehler            '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:write-properties' => 1,
116*a1a3b679SAndreas Boehler            '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:write-acl' => 1,
117*a1a3b679SAndreas Boehler            '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:bind' => 1,
118*a1a3b679SAndreas Boehler            '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:unbind' => 1,
119*a1a3b679SAndreas Boehler            '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:unlock' => 1,
120*a1a3b679SAndreas Boehler            '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:abstract' => 0,
121*a1a3b679SAndreas Boehler        ];
122*a1a3b679SAndreas Boehler
123*a1a3b679SAndreas Boehler
124*a1a3b679SAndreas Boehler        // reloading because php dom sucks
125*a1a3b679SAndreas Boehler        $dom2 = new \DOMDocument('1.0', 'utf-8');
126*a1a3b679SAndreas Boehler        $dom2->loadXML($result);
127*a1a3b679SAndreas Boehler
128*a1a3b679SAndreas Boehler        $dxpath = new \DOMXPath($dom2);
129*a1a3b679SAndreas Boehler        $dxpath->registerNamespace('d','DAV:');
130*a1a3b679SAndreas Boehler        foreach($xpaths as $xpath=>$count) {
131*a1a3b679SAndreas Boehler
132*a1a3b679SAndreas Boehler            $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : ' . $xpath . ', we could only find ' . $dxpath->query($xpath)->length . ' elements, while we expected ' . $count. ' Full XML: ' . $result);
133*a1a3b679SAndreas Boehler
134*a1a3b679SAndreas Boehler        }
135*a1a3b679SAndreas Boehler
136*a1a3b679SAndreas Boehler    }
137*a1a3b679SAndreas Boehler
138*a1a3b679SAndreas Boehler    function testACL() {
139*a1a3b679SAndreas Boehler
140*a1a3b679SAndreas Boehler        $plugin = new Plugin();
141*a1a3b679SAndreas Boehler
142*a1a3b679SAndreas Boehler        $nodes = [
143*a1a3b679SAndreas Boehler            new MockACLNode('foo', [
144*a1a3b679SAndreas Boehler                [
145*a1a3b679SAndreas Boehler                    'principal' => 'principals/admin',
146*a1a3b679SAndreas Boehler                    'privilege' => '{DAV:}read',
147*a1a3b679SAndreas Boehler                ]
148*a1a3b679SAndreas Boehler            ]),
149*a1a3b679SAndreas Boehler            new DAV\SimpleCollection('principals', [
150*a1a3b679SAndreas Boehler                $principal = new MockPrincipal('admin','principals/admin'),
151*a1a3b679SAndreas Boehler            ]),
152*a1a3b679SAndreas Boehler
153*a1a3b679SAndreas Boehler        ];
154*a1a3b679SAndreas Boehler
155*a1a3b679SAndreas Boehler        $server = new DAV\Server($nodes);
156*a1a3b679SAndreas Boehler        $server->addPlugin($plugin);
157*a1a3b679SAndreas Boehler        $authPlugin = new DAV\Auth\Plugin(new DAV\Auth\Backend\Mock(),'realm');
158*a1a3b679SAndreas Boehler        $server->addPlugin($authPlugin);
159*a1a3b679SAndreas Boehler
160*a1a3b679SAndreas Boehler        // Force login
161*a1a3b679SAndreas Boehler        $authPlugin->beforeMethod(new HTTP\Request(), new HTTP\Response());
162*a1a3b679SAndreas Boehler
163*a1a3b679SAndreas Boehler        $requestedProperties = [
164*a1a3b679SAndreas Boehler            '{DAV:}acl',
165*a1a3b679SAndreas Boehler        ];
166*a1a3b679SAndreas Boehler
167*a1a3b679SAndreas Boehler        $result = $server->getPropertiesForPath('foo', $requestedProperties);
168*a1a3b679SAndreas Boehler        $result = $result[0];
169*a1a3b679SAndreas Boehler
170*a1a3b679SAndreas Boehler        $this->assertEquals(1,count($result[200]),'The {DAV:}acl property did not return from the list. Full list: ' . print_r($result, true));
171*a1a3b679SAndreas Boehler        $this->assertArrayHasKey('{DAV:}acl',$result[200]);
172*a1a3b679SAndreas Boehler        $this->assertInstanceOf('Sabre\\DAVACL\\Xml\Property\\Acl', $result[200]['{DAV:}acl']);
173*a1a3b679SAndreas Boehler
174*a1a3b679SAndreas Boehler    }
175*a1a3b679SAndreas Boehler
176*a1a3b679SAndreas Boehler    function testACLRestrictions() {
177*a1a3b679SAndreas Boehler
178*a1a3b679SAndreas Boehler        $plugin = new Plugin();
179*a1a3b679SAndreas Boehler
180*a1a3b679SAndreas Boehler        $nodes = [
181*a1a3b679SAndreas Boehler            new MockACLNode('foo', [
182*a1a3b679SAndreas Boehler                [
183*a1a3b679SAndreas Boehler                    'principal' => 'principals/admin',
184*a1a3b679SAndreas Boehler                    'privilege' => '{DAV:}read',
185*a1a3b679SAndreas Boehler                ]
186*a1a3b679SAndreas Boehler            ]),
187*a1a3b679SAndreas Boehler            new DAV\SimpleCollection('principals', [
188*a1a3b679SAndreas Boehler                $principal = new MockPrincipal('admin','principals/admin'),
189*a1a3b679SAndreas Boehler            ]),
190*a1a3b679SAndreas Boehler
191*a1a3b679SAndreas Boehler        ];
192*a1a3b679SAndreas Boehler
193*a1a3b679SAndreas Boehler        $server = new DAV\Server($nodes);
194*a1a3b679SAndreas Boehler        $server->addPlugin($plugin);
195*a1a3b679SAndreas Boehler        $authPlugin = new DAV\Auth\Plugin(new DAV\Auth\Backend\Mock(),'realm');
196*a1a3b679SAndreas Boehler        $server->addPlugin($authPlugin);
197*a1a3b679SAndreas Boehler
198*a1a3b679SAndreas Boehler        // Force login
199*a1a3b679SAndreas Boehler        $authPlugin->beforeMethod(new HTTP\Request(), new HTTP\Response());
200*a1a3b679SAndreas Boehler
201*a1a3b679SAndreas Boehler        $requestedProperties = [
202*a1a3b679SAndreas Boehler            '{DAV:}acl-restrictions',
203*a1a3b679SAndreas Boehler        ];
204*a1a3b679SAndreas Boehler
205*a1a3b679SAndreas Boehler        $result = $server->getPropertiesForPath('foo', $requestedProperties);
206*a1a3b679SAndreas Boehler        $result = $result[0];
207*a1a3b679SAndreas Boehler
208*a1a3b679SAndreas Boehler        $this->assertEquals(1,count($result[200]),'The {DAV:}acl-restrictions property did not return from the list. Full list: ' . print_r($result, true));
209*a1a3b679SAndreas Boehler        $this->assertArrayHasKey('{DAV:}acl-restrictions',$result[200]);
210*a1a3b679SAndreas Boehler        $this->assertInstanceOf('Sabre\\DAVACL\\Xml\\Property\\AclRestrictions', $result[200]['{DAV:}acl-restrictions']);
211*a1a3b679SAndreas Boehler
212*a1a3b679SAndreas Boehler    }
213*a1a3b679SAndreas Boehler
214*a1a3b679SAndreas Boehler    function testAlternateUriSet() {
215*a1a3b679SAndreas Boehler
216*a1a3b679SAndreas Boehler        $tree = [
217*a1a3b679SAndreas Boehler            new DAV\SimpleCollection('principals', [
218*a1a3b679SAndreas Boehler                $principal = new MockPrincipal('user','principals/user'),
219*a1a3b679SAndreas Boehler            ])
220*a1a3b679SAndreas Boehler        ];
221*a1a3b679SAndreas Boehler
222*a1a3b679SAndreas Boehler        $fakeServer = new DAV\Server($tree);
223*a1a3b679SAndreas Boehler        //$plugin = new DAV\Auth\Plugin(new DAV\Auth\MockBackend(),'realm');
224*a1a3b679SAndreas Boehler        //$fakeServer->addPlugin($plugin);
225*a1a3b679SAndreas Boehler        $plugin = new Plugin();
226*a1a3b679SAndreas Boehler        $fakeServer->addPlugin($plugin);
227*a1a3b679SAndreas Boehler
228*a1a3b679SAndreas Boehler        $requestedProperties = [
229*a1a3b679SAndreas Boehler            '{DAV:}alternate-URI-set',
230*a1a3b679SAndreas Boehler        ];
231*a1a3b679SAndreas Boehler        $result = $fakeServer->getPropertiesForPath('principals/user', $requestedProperties);
232*a1a3b679SAndreas Boehler        $result = $result[0];
233*a1a3b679SAndreas Boehler
234*a1a3b679SAndreas Boehler        $this->assertTrue(isset($result[200]));
235*a1a3b679SAndreas Boehler        $this->assertTrue(isset($result[200]['{DAV:}alternate-URI-set']));
236*a1a3b679SAndreas Boehler        $this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $result[200]['{DAV:}alternate-URI-set']);
237*a1a3b679SAndreas Boehler
238*a1a3b679SAndreas Boehler        $this->assertEquals([], $result[200]['{DAV:}alternate-URI-set']->getHrefs());
239*a1a3b679SAndreas Boehler
240*a1a3b679SAndreas Boehler    }
241*a1a3b679SAndreas Boehler
242*a1a3b679SAndreas Boehler    function testPrincipalURL() {
243*a1a3b679SAndreas Boehler
244*a1a3b679SAndreas Boehler        $tree = [
245*a1a3b679SAndreas Boehler            new DAV\SimpleCollection('principals', [
246*a1a3b679SAndreas Boehler                $principal = new MockPrincipal('user','principals/user'),
247*a1a3b679SAndreas Boehler            ]),
248*a1a3b679SAndreas Boehler        ];
249*a1a3b679SAndreas Boehler
250*a1a3b679SAndreas Boehler        $fakeServer = new DAV\Server($tree);
251*a1a3b679SAndreas Boehler        //$plugin = new DAV\Auth\Plugin(new DAV\Auth\MockBackend(),'realm');
252*a1a3b679SAndreas Boehler        //$fakeServer->addPlugin($plugin);
253*a1a3b679SAndreas Boehler        $plugin = new Plugin();
254*a1a3b679SAndreas Boehler        $fakeServer->addPlugin($plugin);
255*a1a3b679SAndreas Boehler
256*a1a3b679SAndreas Boehler        $requestedProperties = [
257*a1a3b679SAndreas Boehler            '{DAV:}principal-URL',
258*a1a3b679SAndreas Boehler        ];
259*a1a3b679SAndreas Boehler
260*a1a3b679SAndreas Boehler        $result = $fakeServer->getPropertiesForPath('principals/user', $requestedProperties);
261*a1a3b679SAndreas Boehler        $result = $result[0];
262*a1a3b679SAndreas Boehler
263*a1a3b679SAndreas Boehler        $this->assertTrue(isset($result[200]));
264*a1a3b679SAndreas Boehler        $this->assertTrue(isset($result[200]['{DAV:}principal-URL']));
265*a1a3b679SAndreas Boehler        $this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $result[200]['{DAV:}principal-URL']);
266*a1a3b679SAndreas Boehler
267*a1a3b679SAndreas Boehler        $this->assertEquals('principals/user/', $result[200]['{DAV:}principal-URL']->getHref());
268*a1a3b679SAndreas Boehler
269*a1a3b679SAndreas Boehler    }
270*a1a3b679SAndreas Boehler
271*a1a3b679SAndreas Boehler    function testGroupMemberSet() {
272*a1a3b679SAndreas Boehler
273*a1a3b679SAndreas Boehler        $tree = [
274*a1a3b679SAndreas Boehler            new DAV\SimpleCollection('principals', [
275*a1a3b679SAndreas Boehler                $principal = new MockPrincipal('user','principals/user'),
276*a1a3b679SAndreas Boehler            ]),
277*a1a3b679SAndreas Boehler        ];
278*a1a3b679SAndreas Boehler
279*a1a3b679SAndreas Boehler        $fakeServer = new DAV\Server($tree);
280*a1a3b679SAndreas Boehler        //$plugin = new DAV\Auth\Plugin(new DAV\Auth\MockBackend(),'realm');
281*a1a3b679SAndreas Boehler        //$fakeServer->addPlugin($plugin);
282*a1a3b679SAndreas Boehler        $plugin = new Plugin();
283*a1a3b679SAndreas Boehler        $fakeServer->addPlugin($plugin);
284*a1a3b679SAndreas Boehler
285*a1a3b679SAndreas Boehler        $requestedProperties = [
286*a1a3b679SAndreas Boehler            '{DAV:}group-member-set',
287*a1a3b679SAndreas Boehler        ];
288*a1a3b679SAndreas Boehler
289*a1a3b679SAndreas Boehler        $result = $fakeServer->getPropertiesForPath('principals/user', $requestedProperties);
290*a1a3b679SAndreas Boehler        $result = $result[0];
291*a1a3b679SAndreas Boehler
292*a1a3b679SAndreas Boehler        $this->assertTrue(isset($result[200]));
293*a1a3b679SAndreas Boehler        $this->assertTrue(isset($result[200]['{DAV:}group-member-set']));
294*a1a3b679SAndreas Boehler        $this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $result[200]['{DAV:}group-member-set']);
295*a1a3b679SAndreas Boehler
296*a1a3b679SAndreas Boehler        $this->assertEquals([], $result[200]['{DAV:}group-member-set']->getHrefs());
297*a1a3b679SAndreas Boehler
298*a1a3b679SAndreas Boehler    }
299*a1a3b679SAndreas Boehler
300*a1a3b679SAndreas Boehler    function testGroupMemberShip() {
301*a1a3b679SAndreas Boehler
302*a1a3b679SAndreas Boehler        $tree = [
303*a1a3b679SAndreas Boehler            new DAV\SimpleCollection('principals', [
304*a1a3b679SAndreas Boehler                $principal = new MockPrincipal('user','principals/user'),
305*a1a3b679SAndreas Boehler            ]),
306*a1a3b679SAndreas Boehler        ];
307*a1a3b679SAndreas Boehler
308*a1a3b679SAndreas Boehler        $fakeServer = new DAV\Server($tree);
309*a1a3b679SAndreas Boehler        $plugin = new Plugin();
310*a1a3b679SAndreas Boehler        $fakeServer->addPlugin($plugin);
311*a1a3b679SAndreas Boehler
312*a1a3b679SAndreas Boehler        $requestedProperties = [
313*a1a3b679SAndreas Boehler            '{DAV:}group-membership',
314*a1a3b679SAndreas Boehler        ];
315*a1a3b679SAndreas Boehler
316*a1a3b679SAndreas Boehler        $result = $fakeServer->getPropertiesForPath('principals/user', $requestedProperties);
317*a1a3b679SAndreas Boehler        $result = $result[0];
318*a1a3b679SAndreas Boehler
319*a1a3b679SAndreas Boehler        $this->assertTrue(isset($result[200]));
320*a1a3b679SAndreas Boehler        $this->assertTrue(isset($result[200]['{DAV:}group-membership']));
321*a1a3b679SAndreas Boehler        $this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $result[200]['{DAV:}group-membership']);
322*a1a3b679SAndreas Boehler
323*a1a3b679SAndreas Boehler        $this->assertEquals([], $result[200]['{DAV:}group-membership']->getHrefs());
324*a1a3b679SAndreas Boehler
325*a1a3b679SAndreas Boehler    }
326*a1a3b679SAndreas Boehler
327*a1a3b679SAndreas Boehler    function testGetDisplayName() {
328*a1a3b679SAndreas Boehler
329*a1a3b679SAndreas Boehler        $tree = [
330*a1a3b679SAndreas Boehler            new DAV\SimpleCollection('principals', [
331*a1a3b679SAndreas Boehler                $principal = new MockPrincipal('user','principals/user'),
332*a1a3b679SAndreas Boehler            ]),
333*a1a3b679SAndreas Boehler        ];
334*a1a3b679SAndreas Boehler
335*a1a3b679SAndreas Boehler        $fakeServer = new DAV\Server($tree);
336*a1a3b679SAndreas Boehler        $plugin = new Plugin();
337*a1a3b679SAndreas Boehler        $fakeServer->addPlugin($plugin);
338*a1a3b679SAndreas Boehler
339*a1a3b679SAndreas Boehler        $requestedProperties = [
340*a1a3b679SAndreas Boehler            '{DAV:}displayname',
341*a1a3b679SAndreas Boehler        ];
342*a1a3b679SAndreas Boehler
343*a1a3b679SAndreas Boehler        $result = $fakeServer->getPropertiesForPath('principals/user', $requestedProperties);
344*a1a3b679SAndreas Boehler        $result = $result[0];
345*a1a3b679SAndreas Boehler
346*a1a3b679SAndreas Boehler        $this->assertTrue(isset($result[200]));
347*a1a3b679SAndreas Boehler        $this->assertTrue(isset($result[200]['{DAV:}displayname']));
348*a1a3b679SAndreas Boehler
349*a1a3b679SAndreas Boehler        $this->assertEquals('user', $result[200]['{DAV:}displayname']);
350*a1a3b679SAndreas Boehler
351*a1a3b679SAndreas Boehler    }
352*a1a3b679SAndreas Boehler}
353