ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
CalendarQueryReportTest.php
Go to the documentation of this file.
1 <?php
2 
4 
6 use DateTimeZone;
8 
10 
11  protected $elementMap = [
12  '{urn:ietf:params:xml:ns:caldav}calendar-query' => 'Sabre\\CalDAV\\Xml\\Request\CalendarQueryReport',
13  ];
14 
15  function testDeserialize() {
16 
17  $xml = <<<XML
18 <?xml version="1.0"?>
19 <c:calendar-query xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:caldav">
20  <d:prop>
21  <d:getetag />
22  </d:prop>
23  <c:filter>
24  <c:comp-filter name="VCALENDAR" />
25  </c:filter>
26 </c:calendar-query>
27 XML;
28 
29  $result = $this->parse($xml);
30  $calendarQueryReport = new CalendarQueryReport();
31  $calendarQueryReport->properties = [
32  '{DAV:}getetag',
33  ];
34  $calendarQueryReport->filters = [
35  'name' => 'VCALENDAR',
36  'is-not-defined' => false,
37  'comp-filters' => [],
38  'prop-filters' => [],
39  'time-range' => false,
40  ];
41 
42  $this->assertEquals(
43  $calendarQueryReport,
44  $result['value']
45  );
46 
47  }
48 
53 
54  $xml = <<<XML
55 <?xml version="1.0"?>
56 <c:calendar-query xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:caldav">
57  <d:prop>
58  <d:getetag />
59  </d:prop>
60 </c:calendar-query>
61 XML;
62 
63  $this->parse($xml);
64 
65  }
66 
68 
69  $xml = <<<XML
70 <?xml version="1.0"?>
71 <c:calendar-query xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:caldav">
72  <d:prop>
73  <d:getetag />
74  <c:calendar-data content-type="application/json+calendar" version="2.0">
75  <c:expand start="20150101T000000Z" end="20160101T000000Z" />
76  </c:calendar-data>
77  </d:prop>
78  <c:filter>
79  <c:comp-filter name="VCALENDAR">
80  <c:comp-filter name="VEVENT">
81  <c:time-range start="20150101T000000Z" end="20160101T000000Z" />
82  <c:prop-filter name="UID" />
83  <c:comp-filter name="VALARM">
84  <c:is-not-defined />
85  </c:comp-filter>
86  <c:prop-filter name="X-PROP">
87  <c:param-filter name="X-PARAM" />
88  <c:param-filter name="X-PARAM2">
89  <c:is-not-defined />
90  </c:param-filter>
91  <c:param-filter name="X-PARAM3">
92  <c:text-match negate-condition="yes">hi</c:text-match>
93  </c:param-filter>
94  </c:prop-filter>
95  <c:prop-filter name="X-PROP2">
96  <c:is-not-defined />
97  </c:prop-filter>
98  <c:prop-filter name="X-PROP3">
99  <c:time-range start="20150101T000000Z" end="20160101T000000Z" />
100  </c:prop-filter>
101  <c:prop-filter name="X-PROP4">
102  <c:text-match>Hello</c:text-match>
103  </c:prop-filter>
104  </c:comp-filter>
105  </c:comp-filter>
106  </c:filter>
107 </c:calendar-query>
108 XML;
109 
110  $result = $this->parse($xml);
111  $calendarQueryReport = new CalendarQueryReport();
112  $calendarQueryReport->version = '2.0';
113  $calendarQueryReport->contentType = 'application/json+calendar';
114  $calendarQueryReport->properties = [
115  '{DAV:}getetag',
116  '{urn:ietf:params:xml:ns:caldav}calendar-data',
117  ];
118  $calendarQueryReport->expand = [
119  'start' => new DateTimeImmutable('2015-01-01 00:00:00', new DateTimeZone('UTC')),
120  'end' => new DateTimeImmutable('2016-01-01 00:00:00', new DateTimeZone('UTC')),
121  ];
122  $calendarQueryReport->filters = [
123  'name' => 'VCALENDAR',
124  'is-not-defined' => false,
125  'comp-filters' => [
126  [
127  'name' => 'VEVENT',
128  'is-not-defined' => false,
129  'comp-filters' => [
130  [
131  'name' => 'VALARM',
132  'is-not-defined' => true,
133  'comp-filters' => [],
134  'prop-filters' => [],
135  'time-range' => false,
136  ],
137  ],
138  'prop-filters' => [
139  [
140  'name' => 'UID',
141  'is-not-defined' => false,
142  'time-range' => false,
143  'text-match' => null,
144  'param-filters' => [],
145  ],
146  [
147  'name' => 'X-PROP',
148  'is-not-defined' => false,
149  'time-range' => false,
150  'text-match' => null,
151  'param-filters' => [
152  [
153  'name' => 'X-PARAM',
154  'is-not-defined' => false,
155  'text-match' => null,
156  ],
157  [
158  'name' => 'X-PARAM2',
159  'is-not-defined' => true,
160  'text-match' => null,
161  ],
162  [
163  'name' => 'X-PARAM3',
164  'is-not-defined' => false,
165  'text-match' => [
166  'negate-condition' => true,
167  'collation' => 'i;ascii-casemap',
168  'value' => 'hi',
169  ],
170  ],
171  ],
172  ],
173  [
174  'name' => 'X-PROP2',
175  'is-not-defined' => true,
176  'time-range' => false,
177  'text-match' => null,
178  'param-filters' => [],
179  ],
180  [
181  'name' => 'X-PROP3',
182  'is-not-defined' => false,
183  'time-range' => [
184  'start' => new DateTimeImmutable('2015-01-01 00:00:00', new DateTimeZone('UTC')),
185  'end' => new DateTimeImmutable('2016-01-01 00:00:00', new DateTimeZone('UTC')),
186  ],
187  'text-match' => null,
188  'param-filters' => [],
189  ],
190  [
191  'name' => 'X-PROP4',
192  'is-not-defined' => false,
193  'time-range' => false,
194  'text-match' => [
195  'negate-condition' => false,
196  'collation' => 'i;ascii-casemap',
197  'value' => 'Hello',
198  ],
199  'param-filters' => [],
200  ],
201  ],
202  'time-range' => [
203  'start' => new DateTimeImmutable('2015-01-01 00:00:00', new DateTimeZone('UTC')),
204  'end' => new DateTimeImmutable('2016-01-01 00:00:00', new DateTimeZone('UTC')),
205  ]
206  ],
207  ],
208  'prop-filters' => [],
209  'time-range' => false,
210  ];
211 
212  $this->assertEquals(
213  $calendarQueryReport,
214  $result['value']
215  );
216 
217  }
218 
223 
224  $xml = <<<XML
225 <?xml version="1.0"?>
226 <c:calendar-query xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:caldav">
227  <d:prop>
228  <d:getetag />
229  <c:calendar-data content-type="application/json+calendar" version="2.0">
230  <c:expand start="20150101T000000Z" end="20160101T000000Z" />
231  </c:calendar-data>
232  </d:prop>
233  <c:filter>
234  <c:comp-filter name="VCALENDAR" />
235  <c:comp-filter name="VCALENDAR" />
236  </c:filter>
237 </c:calendar-query>
238 XML;
239 
240  $this->parse($xml);
241 
242  }
243 
248 
249  $xml = <<<XML
250 <?xml version="1.0"?>
251 <c:calendar-query xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:caldav">
252  <d:prop>
253  <d:getetag />
254  <c:calendar-data content-type="application/json+calendar" version="2.0">
255  <c:expand start="20150101T000000Z" />
256  </c:calendar-data>
257  </d:prop>
258  <c:filter>
259  <c:comp-filter name="VCALENDAR" />
260  </c:filter>
261 </c:calendar-query>
262 XML;
263 
264  $this->parse($xml);
265 
266  }
267 
272 
273  $xml = <<<XML
274 <?xml version="1.0"?>
275 <c:calendar-query xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:caldav">
276  <d:prop>
277  <d:getetag />
278  <c:calendar-data content-type="application/json+calendar" version="2.0">
279  <c:expand start="20150101T000000Z" end="20140101T000000Z" />
280  </c:calendar-data>
281  </d:prop>
282  <c:filter>
283  <c:comp-filter name="VCALENDAR" />
284  </c:filter>
285 </c:calendar-query>
286 XML;
287 
288  $this->parse($xml);
289 
290  }
291 
296 
297  $xml = <<<XML
298 <?xml version="1.0"?>
299 <c:calendar-query xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:caldav">
300  <d:prop>
301  <d:getetag />
302  <c:calendar-data />
303  </d:prop>
304  <c:filter>
305  <c:comp-filter name="VCALENDAR">
306  <c:time-range start="20150101T000000Z" end="20160101T000000Z" />
307  </c:comp-filter>
308  </c:filter>
309 </c:calendar-query>
310 XML;
311 
312  $this->parse($xml);
313 
314  }
315 
320 
321  $xml = <<<XML
322 <?xml version="1.0"?>
323 <c:calendar-query xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:caldav">
324  <d:prop>
325  <d:getetag />
326  <c:calendar-data />
327  </d:prop>
328  <c:filter>
329  <c:comp-filter name="VCALENDAR">
330  <c:comp-filter name="VEVENT">
331  <c:time-range start="20150101T000000Z" end="20140101T000000Z" />
332  </c:comp-filter>
333  </c:comp-filter>
334  </c:filter>
335 </c:calendar-query>
336 XML;
337 
338  $this->parse($xml);
339 
340  }
341 
346 
347  $xml = <<<XML
348 <?xml version="1.0"?>
349 <c:calendar-query xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:caldav">
350  <d:prop>
351  <d:getetag />
352  <c:calendar-data />
353  </d:prop>
354  <c:filter>
355  <c:comp-filter name="VCALENDAR">
356  <c:comp-filter name="VEVENT">
357  <c:prop-filter name="DTSTART">
358  <c:time-range start="20150101T000000Z" end="20140101T000000Z" />
359  </c:prop-filter>
360  </c:comp-filter>
361  </c:comp-filter>
362  </c:filter>
363 </c:calendar-query>
364 XML;
365 
366  $this->parse($xml);
367 
368  }
369 }
$result
parse($xml, array $elementMap=[])
Definition: XmlTest.php:26
$this data['403_header']
CalendarQueryReport request parser.
expand()
Definition: expand.php:2