ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
AddressBookQueryReportTest.php
Go to the documentation of this file.
1 <?php
2 
4 
6 
8 
9  protected $elementMap = [
10  '{urn:ietf:params:xml:ns:carddav}addressbook-query' => 'Sabre\\CardDAV\\Xml\\Request\AddressBookQueryReport',
11  ];
12 
13  function testDeserialize() {
14 
15  $xml = <<<XML
16 <?xml version="1.0"?>
17 <c:addressbook-query xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:carddav">
18  <d:prop>
19  <d:getetag />
20  </d:prop>
21  <c:filter>
22  <c:prop-filter name="uid" />
23  </c:filter>
24 </c:addressbook-query>
25 XML;
26 
27  $result = $this->parse($xml);
28  $addressBookQueryReport = new AddressBookQueryReport();
29  $addressBookQueryReport->properties = [
30  '{DAV:}getetag',
31  ];
32  $addressBookQueryReport->test = 'anyof';
33  $addressBookQueryReport->filters = [
34  [
35  'name' => 'uid',
36  'test' => 'anyof',
37  'is-not-defined' => false,
38  'param-filters' => [],
39  'text-matches' => [],
40  ]
41  ];
42 
43  $this->assertEquals(
44  $addressBookQueryReport,
45  $result['value']
46  );
47 
48  }
49 
50  function testDeserializeAllOf() {
51 
52  $xml = <<<XML
53 <?xml version="1.0"?>
54 <c:addressbook-query xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:carddav">
55  <d:prop>
56  <d:getetag />
57  </d:prop>
58  <c:filter test="allof">
59  <c:prop-filter name="uid" />
60  </c:filter>
61 </c:addressbook-query>
62 XML;
63 
64  $result = $this->parse($xml);
65  $addressBookQueryReport = new AddressBookQueryReport();
66  $addressBookQueryReport->properties = [
67  '{DAV:}getetag',
68  ];
69  $addressBookQueryReport->test = 'allof';
70  $addressBookQueryReport->filters = [
71  [
72  'name' => 'uid',
73  'test' => 'anyof',
74  'is-not-defined' => false,
75  'param-filters' => [],
76  'text-matches' => [],
77  ]
78  ];
79 
80  $this->assertEquals(
81  $addressBookQueryReport,
82  $result['value']
83  );
84 
85  }
86 
91 
92  $xml = <<<XML
93 <?xml version="1.0"?>
94 <c:addressbook-query xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:carddav">
95  <d:prop>
96  <d:getetag />
97  </d:prop>
98  <c:filter test="bad">
99  <c:prop-filter name="uid" />
100  </c:filter>
101 </c:addressbook-query>
102 XML;
103 
104  $this->parse($xml);
105 
106  }
107 
112 
113  $xml = <<<XML
114 <?xml version="1.0"?>
115 <c:addressbook-query xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:carddav">
116  <d:prop>
117  <d:getetag />
118  </d:prop>
119 </c:addressbook-query>
120 XML;
121 
122  $result = $this->parse($xml);
123  $addressBookQueryReport = new AddressBookQueryReport();
124  $addressBookQueryReport->properties = [
125  '{DAV:}getetag',
126  ];
127  $addressBookQueryReport->test = 'anyof';
128  $addressBookQueryReport->filters = [];
129 
130  $this->assertEquals(
131  $addressBookQueryReport,
132  $result['value']
133  );
134 
135  }
136 
138 
139  $xml = <<<XML
140 <?xml version="1.0"?>
141 <c:addressbook-query xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:carddav">
142  <d:prop>
143  <d:getetag />
144  <c:address-data content-type="application/vcard+json" version="4.0" />
145  </d:prop>
146  <c:filter>
147  <c:prop-filter name="uid">
148  <c:is-not-defined />
149  </c:prop-filter>
150  <c:prop-filter name="x-foo" test="allof">
151  <c:param-filter name="x-param1" />
152  <c:param-filter name="x-param2">
153  <c:is-not-defined />
154  </c:param-filter>
155  <c:param-filter name="x-param3">
156  <c:text-match match-type="contains">Hello!</c:text-match>
157  </c:param-filter>
158  </c:prop-filter>
159  <c:prop-filter name="x-prop2">
160  <c:text-match match-type="starts-with" negate-condition="yes">No</c:text-match>
161  </c:prop-filter>
162  </c:filter>
163  <c:limit><c:nresults>10</c:nresults></c:limit>
164 </c:addressbook-query>
165 XML;
166 
167  $result = $this->parse($xml);
168  $addressBookQueryReport = new AddressBookQueryReport();
169  $addressBookQueryReport->properties = [
170  '{DAV:}getetag',
171  '{urn:ietf:params:xml:ns:carddav}address-data',
172  ];
173  $addressBookQueryReport->test = 'anyof';
174  $addressBookQueryReport->filters = [
175  [
176  'name' => 'uid',
177  'test' => 'anyof',
178  'is-not-defined' => true,
179  'param-filters' => [],
180  'text-matches' => [],
181  ],
182  [
183  'name' => 'x-foo',
184  'test' => 'allof',
185  'is-not-defined' => false,
186  'param-filters' => [
187  [
188  'name' => 'x-param1',
189  'is-not-defined' => false,
190  'text-match' => null,
191  ],
192  [
193  'name' => 'x-param2',
194  'is-not-defined' => true,
195  'text-match' => null,
196  ],
197  [
198  'name' => 'x-param3',
199  'is-not-defined' => false,
200  'text-match' => [
201  'negate-condition' => false,
202  'value' => 'Hello!',
203  'match-type' => 'contains',
204  'collation' => 'i;unicode-casemap',
205  ],
206  ],
207  ],
208  'text-matches' => [],
209  ],
210  [
211  'name' => 'x-prop2',
212  'test' => 'anyof',
213  'is-not-defined' => false,
214  'param-filters' => [],
215  'text-matches' => [
216  [
217  'negate-condition' => true,
218  'value' => 'No',
219  'match-type' => 'starts-with',
220  'collation' => 'i;unicode-casemap',
221  ],
222  ],
223  ]
224  ];
225 
226  $addressBookQueryReport->version = '4.0';
227  $addressBookQueryReport->contentType = 'application/vcard+json';
228  $addressBookQueryReport->limit = 10;
229 
230  $this->assertEquals(
231  $addressBookQueryReport,
232  $result['value']
233  );
234 
235  }
236 
241 
242  $xml = <<<XML
243 <?xml version="1.0"?>
244 <c:addressbook-query xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:carddav">
245  <d:prop>
246  <d:getetag />
247  </d:prop>
248  <c:filter>
249  <c:prop-filter name="x-foo" test="allof">
250  <c:param-filter name="x-param3">
251  <c:text-match match-type="bad">Hello!</c:text-match>
252  </c:param-filter>
253  </c:prop-filter>
254  </c:filter>
255 </c:addressbook-query>
256 XML;
257  $this->parse($xml);
258 
259  }
260 
265 
266  $xml = <<<XML
267 <?xml version="1.0"?>
268 <c:addressbook-query xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:carddav">
269  <d:prop>
270  <d:getetag />
271  </d:prop>
272  <c:filter>
273  <c:prop-filter name="x-prop2">
274  <c:text-match match-type="bad" negate-condition="yes">No</c:text-match>
275  </c:prop-filter>
276  </c:filter>
277 </c:addressbook-query>
278 XML;
279  $this->parse($xml);
280 
281  }
282 
287 
288  $xml = <<<XML
289 <?xml version="1.0"?>
290 <c:addressbook-query xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:carddav">
291  <d:prop>
292  <d:getetag />
293  </d:prop>
294  <c:filter>
295  </c:filter>
296  <c:filter>
297  </c:filter>
298 </c:addressbook-query>
299 XML;
300  $this->parse($xml);
301 
302  }
303 
305 
306  $xml = <<<XML
307 <?xml version="1.0"?>
308 <c:addressbook-query xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:carddav">
309  <d:prop>
310  <d:getetag />
311  <c:address-data>
312  <c:prop name="VERSION"/>
313  <c:prop name="UID"/>
314  <c:prop name="NICKNAME"/>
315  <c:prop name="EMAIL"/>
316  <c:prop name="FN"/>
317  <c:prop name="TEL"/>
318  </c:address-data>
319  </d:prop>
320 </c:addressbook-query>
321 XML;
322 
323  $result = $this->parse($xml);
324  $addressBookQueryReport = new AddressBookQueryReport();
325  $addressBookQueryReport->properties = [
326  '{DAV:}getetag',
327  '{urn:ietf:params:xml:ns:carddav}address-data'
328  ];
329  $addressBookQueryReport->filters = [];
330  $addressBookQueryReport->test = 'anyof';
331  $addressBookQueryReport->contentType = 'text/vcard';
332  $addressBookQueryReport->version = '3.0';
333  $addressBookQueryReport->addressDataProperties = [
334  'VERSION',
335  'UID',
336  'NICKNAME',
337  'EMAIL',
338  'FN',
339  'TEL',
340  ];
341 
342  $this->assertEquals(
343  $addressBookQueryReport,
344  $result['value']
345  );
346 
347  }
348 
349 
350 }
$result
testDeserializeNoFilter()
We should error on this, but KDE does this, so we chose to support it.
parse($xml, array $elementMap=[])
Definition: XmlTest.php:26
test()
Definition: build.php:107
$this data['403_header']