ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Sabre\DAVACL\ExpandPropertiesTest Class Reference
+ Inheritance diagram for Sabre\DAVACL\ExpandPropertiesTest:
+ Collaboration diagram for Sabre\DAVACL\ExpandPropertiesTest:

Public Member Functions

 getServer ()
 
 testSimple ()
 
 testExpand ()
 testSimple More...
 
 testExpandHrefList ()
 testSimple More...
 
 testExpandDeep ()
 testExpand More...
 

Detailed Description

Definition at line 10 of file ExpandPropertiesTest.php.

Member Function Documentation

◆ getServer()

Sabre\DAVACL\ExpandPropertiesTest::getServer ( )

Definition at line 12 of file ExpandPropertiesTest.php.

References $tree.

Referenced by Sabre\DAVACL\ExpandPropertiesTest\testExpand(), Sabre\DAVACL\ExpandPropertiesTest\testExpandDeep(), Sabre\DAVACL\ExpandPropertiesTest\testExpandHrefList(), and Sabre\DAVACL\ExpandPropertiesTest\testSimple().

12  {
13 
14  $tree = [
15  new DAV\Mock\PropertiesCollection('node1', [], [
16  '{http://sabredav.org/ns}simple' => 'foo',
17  '{http://sabredav.org/ns}href' => new DAV\Xml\Property\Href('node2'),
18  '{DAV:}displayname' => 'Node 1',
19  ]),
20  new DAV\Mock\PropertiesCollection('node2', [], [
21  '{http://sabredav.org/ns}simple' => 'simple',
22  '{http://sabredav.org/ns}hreflist' => new DAV\Xml\Property\Href(['node1', 'node3']),
23  '{DAV:}displayname' => 'Node 2',
24  ]),
25  new DAV\Mock\PropertiesCollection('node3', [], [
26  '{http://sabredav.org/ns}simple' => 'simple',
27  '{DAV:}displayname' => 'Node 3',
28  ]),
29  ];
30 
31  $fakeServer = new DAV\Server($tree);
32  $fakeServer->sapi = new HTTP\SapiMock();
33  $fakeServer->debugExceptions = true;
34  $fakeServer->httpResponse = new HTTP\ResponseMock();
35  $plugin = new Plugin();
36  $plugin->allowUnauthenticatedAccess = false;
37  // Anyone can do anything
38  $plugin->setDefaultACL([
39  [
40  'principal' => '{DAV:}all',
41  'privilege' => '{DAV:}all',
42  ]
43  ]);
44  $this->assertTrue($plugin instanceof Plugin);
45 
46  $fakeServer->addPlugin($plugin);
47  $this->assertEquals($plugin, $fakeServer->getPlugin('acl'));
48 
49  return $fakeServer;
50 
51  }
+ Here is the caller graph for this function:

◆ testExpand()

Sabre\DAVACL\ExpandPropertiesTest::testExpand ( )

testSimple

Definition at line 117 of file ExpandPropertiesTest.php.

References $request, $result, $server, $xml, Sabre\HTTP\Sapi\createFromServerArray(), Sabre\DAVACL\ExpandPropertiesTest\getServer(), and Sabre\DAV\Version\VERSION.

117  {
118 
119  $xml = '<?xml version="1.0"?>
120 <d:expand-property xmlns:d="DAV:">
121  <d:property name="href" namespace="http://sabredav.org/ns">
122  <d:property name="displayname" />
123  </d:property>
124 </d:expand-property>';
125 
126  $serverVars = [
127  'REQUEST_METHOD' => 'REPORT',
128  'HTTP_DEPTH' => '0',
129  'REQUEST_URI' => '/node1',
130  ];
131 
133  $request->setBody($xml);
134 
135  $server = $this->getServer();
136  $server->httpRequest = $request;
137 
138  $server->exec();
139 
140  $this->assertEquals(207, $server->httpResponse->status, 'Incorrect response status received. Full response body: ' . $server->httpResponse->body);
141  $this->assertEquals([
142  'X-Sabre-Version' => [DAV\Version::VERSION],
143  'Content-Type' => ['application/xml; charset=utf-8'],
144  ], $server->httpResponse->getHeaders());
145 
146 
147  $check = [
148  '/d:multistatus',
149  '/d:multistatus/d:response' => 1,
150  '/d:multistatus/d:response/d:href' => 1,
151  '/d:multistatus/d:response/d:propstat' => 1,
152  '/d:multistatus/d:response/d:propstat/d:prop' => 1,
153  '/d:multistatus/d:response/d:propstat/d:prop/s:href' => 1,
154  '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response' => 1,
155  '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response/d:href' => 1,
156  '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response/d:propstat' => 1,
157  '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response/d:propstat/d:prop' => 1,
158  '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response/d:propstat/d:prop/d:displayname' => 1,
159  ];
160 
161  $xml = simplexml_load_string($server->httpResponse->body);
162  $xml->registerXPathNamespace('d', 'DAV:');
163  $xml->registerXPathNamespace('s', 'http://sabredav.org/ns');
164  foreach ($check as $v1 => $v2) {
165 
166  $xpath = is_int($v1) ? $v2 : $v1;
167 
168  $result = $xml->xpath($xpath);
169 
170  $count = 1;
171  if (!is_int($v1)) $count = $v2;
172 
173  $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . ' Full response body: ' . $server->httpResponse->getBodyAsString());
174 
175  }
176 
177  }
$result
foreach($paths as $path) $request
Definition: asyncclient.php:32
$server
Definition: sabredav.php:48
const VERSION
Full version number.
Definition: Version.php:17
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.
Definition: Sapi.php:107
+ Here is the call graph for this function:

◆ testExpandDeep()

Sabre\DAVACL\ExpandPropertiesTest::testExpandDeep ( )

testExpand

Definition at line 247 of file ExpandPropertiesTest.php.

References $request, $result, $server, $xml, Sabre\HTTP\Sapi\createFromServerArray(), Sabre\DAVACL\ExpandPropertiesTest\getServer(), and Sabre\DAV\Version\VERSION.

247  {
248 
249  $xml = '<?xml version="1.0"?>
250 <d:expand-property xmlns:d="DAV:">
251  <d:property name="hreflist" namespace="http://sabredav.org/ns">
252  <d:property name="href" namespace="http://sabredav.org/ns">
253  <d:property name="displayname" />
254  </d:property>
255  <d:property name="displayname" />
256  </d:property>
257 </d:expand-property>';
258 
259  $serverVars = [
260  'REQUEST_METHOD' => 'REPORT',
261  'HTTP_DEPTH' => '0',
262  'REQUEST_URI' => '/node2',
263  ];
264 
266  $request->setBody($xml);
267 
268  $server = $this->getServer();
269  $server->httpRequest = $request;
270 
271  $server->exec();
272 
273  $this->assertEquals(207, $server->httpResponse->status);
274  $this->assertEquals([
275  'X-Sabre-Version' => [DAV\Version::VERSION],
276  'Content-Type' => ['application/xml; charset=utf-8'],
277  ], $server->httpResponse->getHeaders());
278 
279 
280  $check = [
281  '/d:multistatus',
282  '/d:multistatus/d:response' => 1,
283  '/d:multistatus/d:response/d:href' => 1,
284  '/d:multistatus/d:response/d:propstat' => 1,
285  '/d:multistatus/d:response/d:propstat/d:prop' => 1,
286  '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist' => 1,
287  '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response' => 2,
288  '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:href' => 2,
289  '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat' => 3,
290  '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop' => 3,
291  '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/d:displayname' => 2,
292  '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href' => 2,
293  '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response' => 1,
294  '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response/d:href' => 1,
295  '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response/d:propstat' => 1,
296  '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response/d:propstat/d:prop' => 1,
297  '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response/d:propstat/d:prop/d:displayname' => 1,
298  ];
299 
300  $xml = simplexml_load_string($server->httpResponse->body);
301  $xml->registerXPathNamespace('d', 'DAV:');
302  $xml->registerXPathNamespace('s', 'http://sabredav.org/ns');
303  foreach ($check as $v1 => $v2) {
304 
305  $xpath = is_int($v1) ? $v2 : $v1;
306 
307  $result = $xml->xpath($xpath);
308 
309  $count = 1;
310  if (!is_int($v1)) $count = $v2;
311 
312  $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result));
313 
314  }
315 
316  }
$result
foreach($paths as $path) $request
Definition: asyncclient.php:32
$server
Definition: sabredav.php:48
const VERSION
Full version number.
Definition: Version.php:17
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.
Definition: Sapi.php:107
+ Here is the call graph for this function:

◆ testExpandHrefList()

Sabre\DAVACL\ExpandPropertiesTest::testExpandHrefList ( )

testSimple

Definition at line 182 of file ExpandPropertiesTest.php.

References $request, $result, $server, $xml, Sabre\HTTP\Sapi\createFromServerArray(), Sabre\DAVACL\ExpandPropertiesTest\getServer(), and Sabre\DAV\Version\VERSION.

182  {
183 
184  $xml = '<?xml version="1.0"?>
185 <d:expand-property xmlns:d="DAV:">
186  <d:property name="hreflist" namespace="http://sabredav.org/ns">
187  <d:property name="displayname" />
188  </d:property>
189 </d:expand-property>';
190 
191  $serverVars = [
192  'REQUEST_METHOD' => 'REPORT',
193  'HTTP_DEPTH' => '0',
194  'REQUEST_URI' => '/node2',
195  ];
196 
198  $request->setBody($xml);
199 
200  $server = $this->getServer();
201  $server->httpRequest = $request;
202 
203  $server->exec();
204 
205  $this->assertEquals(207, $server->httpResponse->status);
206  $this->assertEquals([
207  'X-Sabre-Version' => [DAV\Version::VERSION],
208  'Content-Type' => ['application/xml; charset=utf-8'],
209  ], $server->httpResponse->getHeaders());
210 
211 
212  $check = [
213  '/d:multistatus',
214  '/d:multistatus/d:response' => 1,
215  '/d:multistatus/d:response/d:href' => 1,
216  '/d:multistatus/d:response/d:propstat' => 1,
217  '/d:multistatus/d:response/d:propstat/d:prop' => 1,
218  '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist' => 1,
219  '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response' => 2,
220  '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:href' => 2,
221  '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat' => 2,
222  '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop' => 2,
223  '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/d:displayname' => 2,
224  ];
225 
226  $xml = simplexml_load_string($server->httpResponse->body);
227  $xml->registerXPathNamespace('d', 'DAV:');
228  $xml->registerXPathNamespace('s', 'http://sabredav.org/ns');
229  foreach ($check as $v1 => $v2) {
230 
231  $xpath = is_int($v1) ? $v2 : $v1;
232 
233  $result = $xml->xpath($xpath);
234 
235  $count = 1;
236  if (!is_int($v1)) $count = $v2;
237 
238  $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result));
239 
240  }
241 
242  }
$result
foreach($paths as $path) $request
Definition: asyncclient.php:32
$server
Definition: sabredav.php:48
const VERSION
Full version number.
Definition: Version.php:17
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.
Definition: Sapi.php:107
+ Here is the call graph for this function:

◆ testSimple()

Sabre\DAVACL\ExpandPropertiesTest::testSimple ( )

Definition at line 53 of file ExpandPropertiesTest.php.

References $request, $result, $server, $xml, Sabre\HTTP\Sapi\createFromServerArray(), Sabre\DAVACL\ExpandPropertiesTest\getServer(), and Sabre\DAV\Version\VERSION.

53  {
54 
55  $xml = '<?xml version="1.0"?>
56 <d:expand-property xmlns:d="DAV:">
57  <d:property name="displayname" />
58  <d:property name="foo" namespace="http://www.sabredav.org/NS/2010/nonexistant" />
59  <d:property name="simple" namespace="http://sabredav.org/ns" />
60  <d:property name="href" namespace="http://sabredav.org/ns" />
61 </d:expand-property>';
62 
63  $serverVars = [
64  'REQUEST_METHOD' => 'REPORT',
65  'HTTP_DEPTH' => '0',
66  'REQUEST_URI' => '/node1',
67  ];
68 
70  $request->setBody($xml);
71 
72  $server = $this->getServer();
73  $server->httpRequest = $request;
74 
75  $server->exec();
76 
77  $this->assertEquals(207, $server->httpResponse->status, 'Incorrect status code received. Full body: ' . $server->httpResponse->body);
78  $this->assertEquals([
79  'X-Sabre-Version' => [DAV\Version::VERSION],
80  'Content-Type' => ['application/xml; charset=utf-8'],
81  ], $server->httpResponse->getHeaders());
82 
83 
84  $check = [
85  '/d:multistatus',
86  '/d:multistatus/d:response' => 1,
87  '/d:multistatus/d:response/d:href' => 1,
88  '/d:multistatus/d:response/d:propstat' => 2,
89  '/d:multistatus/d:response/d:propstat/d:prop' => 2,
90  '/d:multistatus/d:response/d:propstat/d:prop/d:displayname' => 1,
91  '/d:multistatus/d:response/d:propstat/d:prop/s:simple' => 1,
92  '/d:multistatus/d:response/d:propstat/d:prop/s:href' => 1,
93  '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:href' => 1,
94  ];
95 
96  $xml = simplexml_load_string($server->httpResponse->body);
97  $xml->registerXPathNamespace('d', 'DAV:');
98  $xml->registerXPathNamespace('s', 'http://sabredav.org/ns');
99  foreach ($check as $v1 => $v2) {
100 
101  $xpath = is_int($v1) ? $v2 : $v1;
102 
103  $result = $xml->xpath($xpath);
104 
105  $count = 1;
106  if (!is_int($v1)) $count = $v2;
107 
108  $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . '. Full response: ' . $server->httpResponse->body);
109 
110  }
111 
112  }
$result
foreach($paths as $path) $request
Definition: asyncclient.php:32
$server
Definition: sabredav.php:48
const VERSION
Full version number.
Definition: Version.php:17
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.
Definition: Sapi.php:107
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: