ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
PrincipalMatchTest.php
Go to the documentation of this file.
1<?php
2
3namespace Sabre\DAVACL;
4
6
8
9 public $setupACL = true;
10 public $autoLogin = 'user1';
11
12 function testPrincipalMatch() {
13
14 $xml = <<<XML
15<?xml version="1.0"?>
16<principal-match xmlns="DAV:">
17 <self />
18</principal-match>
19XML;
20
21 $request = new Request('REPORT', '/principals', ['Content-Type' => 'application/xml']);
22 $request->setBody($xml);
23
24 $response = $this->request($request, 207);
25
26 $expected = <<<XML
27<?xml version="1.0"?>
28<d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
29 <d:status>HTTP/1.1 200 OK</d:status>
30 <d:href>/principals/user1</d:href>
31 <d:propstat>
32 <d:prop/>
33 <d:status>HTTP/1.1 418 I'm a teapot</d:status>
34 </d:propstat>
35</d:multistatus>
36XML;
37
38 $this->assertXmlStringEqualsXmlString(
39 $expected,
40 $response->getBodyAsString()
41 );
42
43 }
44
45 function testPrincipalMatchProp() {
46
47 $xml = <<<XML
48<?xml version="1.0"?>
49<principal-match xmlns="DAV:">
50 <self />
51 <prop>
52 <resourcetype />
53 </prop>
54</principal-match>
55XML;
56
57 $request = new Request('REPORT', '/principals', ['Content-Type' => 'application/xml']);
58 $request->setBody($xml);
59
60 $response = $this->request($request, 207);
61
62 $expected = <<<XML
63<?xml version="1.0"?>
64<d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
65 <d:status>HTTP/1.1 200 OK</d:status>
66 <d:href>/principals/user1/</d:href>
67 <d:propstat>
68 <d:prop>
69 <d:resourcetype><d:principal/></d:resourcetype>
70 </d:prop>
71 <d:status>HTTP/1.1 200 OK</d:status>
72 </d:propstat>
73</d:multistatus>
74XML;
75
76 $this->assertXmlStringEqualsXmlString(
77 $expected,
78 $response->getBodyAsString()
79 );
80
81 }
82
83 function testPrincipalMatchPrincipalProperty() {
84
85 $xml = <<<XML
86<?xml version="1.0"?>
87<principal-match xmlns="DAV:">
88 <principal-property>
89 <principal-URL />
90 </principal-property>
91 <prop>
92 <resourcetype />
93 </prop>
94</principal-match>
95XML;
96
97 $request = new Request('REPORT', '/principals', ['Content-Type' => 'application/xml']);
98 $request->setBody($xml);
99
100 $response = $this->request($request, 207);
101
102 $expected = <<<XML
103<?xml version="1.0"?>
104<d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
105 <d:status>HTTP/1.1 200 OK</d:status>
106 <d:href>/principals/user1/</d:href>
107 <d:propstat>
108 <d:prop>
109 <d:resourcetype><d:principal/></d:resourcetype>
110 </d:prop>
111 <d:status>HTTP/1.1 200 OK</d:status>
112 </d:propstat>
113</d:multistatus>
114XML;
115
116 $this->assertXmlStringEqualsXmlString(
117 $expected,
118 $response->getBodyAsString()
119 );
120
121 }
122
123}
foreach($paths as $path) $request
Definition: asyncclient.php:32
An exception for terminatinating execution or to throw for unit testing.
This class may be used as a basis for other webdav-related unittests.
request($request, $expectedStatus=null)
Makes a request, and returns a response object.
The Request class represents a single HTTP request.
Definition: Request.php:18
$response