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

Public Member Functions

 testGetClark ()
 
 testGetClarkNoNS ()
 
 testGetClarkNotOnAnElement ()
 
 testSimple ()
 
 testCDATA ()
 
 testSimpleNamespacedAttribute ()
 
 testMappedElement ()
 
 testMappedElementBadClass ()
 
 testMappedElementCallBack ()
 testMappedElement More...
 
 testMappedElementCallBackNoNamespace ()
 testMappedElementCallBack More...
 
 testReadText ()
 testMappedElementCallBack More...
 
 testParseProblem ()
 
 testBrokenParserClass ()
 
 testBrokenXml ()
 Test was added for Issue #10. More...
 
 testBrokenXml2 ()
 Test was added for Issue #45. More...
 
 testParseInnerTree ()
 testMappedElement More...
 
 testParseGetElements ()
 testParseInnerTree More...
 
 testParseGetElementsNoElements ()
 testParseInnerTree More...
 

Detailed Description

Definition at line 5 of file ReaderTest.php.

Member Function Documentation

◆ testBrokenParserClass()

Sabre\Xml\ReaderTest::testBrokenParserClass ( )

Definition at line 365 of file ReaderTest.php.

References $input, and $reader.

365  {
366 
367  $input = <<<BLA
368 <?xml version="1.0"?>
369 <root xmlns="http://sabredav.org/ns">
370 <elem1 />
371 </root>
372 BLA;
373 
374  $reader = new Reader();
375  $reader->elementMap = [
376  '{http://sabredav.org/ns}elem1' => 'Sabre\\Xml\\Element\\Eater'
377  ];
378  $reader->xml($input);
379  $reader->parse();
380 
381 
382  }

◆ testBrokenXml()

Sabre\Xml\ReaderTest::testBrokenXml ( )

Test was added for Issue #10.

Sabre

Definition at line 389 of file ReaderTest.php.

References $input, $reader, and test().

389  {
390 
391  $input = <<<BLA
392 <test>
393 <hello>
394 </hello>
395 </sffsdf>
396 BLA;
397 
398  $reader = new Reader();
399  $reader->xml($input);
400  $reader->parse();
401 
402  }
test()
Definition: build.php:107
+ Here is the call graph for this function:

◆ testBrokenXml2()

Sabre\Xml\ReaderTest::testBrokenXml2 ( )

Test was added for Issue #45.

Sabre

Definition at line 409 of file ReaderTest.php.

References $input.

409  {
410 
411  $input = <<<XML
412 <?xml version="1.0" encoding="UTF-8"?>
413 <definitions>
414  <collaboration>
415  <participant id="sid-A33D08EB-A2DE-448F-86FE-A2B62E98818" name="Company" processRef="sid-A0A6A196-3C9A-4C69-88F6-7ED7DDFDD264">
416  <extensionElements>
417  <signavio:signavioMetaData metaKey="bgcolor" />
418  ""Administrative w">
419  <extensionElements>
420  <signavio:signavioMetaData metaKey="bgcolor" metaValue=""/>
421  </extensionElements>
422  </lan
423 XML;
424  $reader = new Reader();
425  $reader->xml($input);
426  $reader->parse();
427 
428  }

◆ testCDATA()

Sabre\Xml\ReaderTest::testCDATA ( )

Definition at line 97 of file ReaderTest.php.

References $input, Sabre\VObject\$output, and $reader.

97  {
98 
99  $input = <<<BLA
100 <?xml version="1.0"?>
101 <root xmlns="http://sabredav.org/ns">
102  <foo><![CDATA[bar]]></foo>
103 </root>
104 BLA;
105 
106  $reader = new Reader();
107  $reader->xml($input);
108 
109  $output = $reader->parse();
110 
111  $expected = [
112  'name' => '{http://sabredav.org/ns}root',
113  'value' => [
114  [
115  'name' => '{http://sabredav.org/ns}foo',
116  'value' => 'bar',
117  'attributes' => [],
118  ],
119 
120  ],
121  'attributes' => [],
122 
123  ];
124 
125  $this->assertEquals($expected, $output);
126 
127  }

◆ testGetClark()

Sabre\Xml\ReaderTest::testGetClark ( )

Definition at line 7 of file ReaderTest.php.

References $input, and $reader.

7  {
8 
9  $input = <<<BLA
10 <?xml version="1.0"?>
11 <root xmlns="http://sabredav.org/ns" />
12 BLA;
13  $reader = new Reader();
14  $reader->xml($input);
15 
16  $reader->next();
17 
18  $this->assertEquals('{http://sabredav.org/ns}root', $reader->getClark());
19 
20  }

◆ testGetClarkNoNS()

Sabre\Xml\ReaderTest::testGetClarkNoNS ( )

Definition at line 22 of file ReaderTest.php.

References $input, and $reader.

22  {
23 
24  $input = <<<BLA
25 <?xml version="1.0"?>
26 <root />
27 BLA;
28  $reader = new Reader();
29  $reader->xml($input);
30 
31  $reader->next();
32 
33  $this->assertEquals('{}root', $reader->getClark());
34 
35  }

◆ testGetClarkNotOnAnElement()

Sabre\Xml\ReaderTest::testGetClarkNotOnAnElement ( )

Definition at line 37 of file ReaderTest.php.

References $input, and $reader.

37  {
38 
39  $input = <<<BLA
40 <?xml version="1.0"?>
41 <root />
42 BLA;
43  $reader = new Reader();
44  $reader->xml($input);
45 
46  $this->assertNull($reader->getClark());
47  }

◆ testMappedElement()

Sabre\Xml\ReaderTest::testMappedElement ( )

Definition at line 161 of file ReaderTest.php.

References $input, Sabre\VObject\$output, and $reader.

161  {
162 
163  $input = <<<BLA
164 <?xml version="1.0"?>
165 <root xmlns="http://sabredav.org/ns">
166  <elem1 />
167 </root>
168 BLA;
169 
170  $reader = new Reader();
171  $reader->elementMap = [
172  '{http://sabredav.org/ns}elem1' => 'Sabre\\Xml\\Element\\Mock'
173  ];
174  $reader->xml($input);
175 
176  $output = $reader->parse();
177 
178  $expected = [
179  'name' => '{http://sabredav.org/ns}root',
180  'value' => [
181  [
182  'name' => '{http://sabredav.org/ns}elem1',
183  'value' => 'foobar',
184  'attributes' => [],
185  ],
186  ],
187  'attributes' => [],
188 
189  ];
190 
191  $this->assertEquals($expected, $output);
192 
193  }

◆ testMappedElementBadClass()

Sabre\Xml\ReaderTest::testMappedElementBadClass ( )

Definition at line 198 of file ReaderTest.php.

References $input, and $reader.

198  {
199 
200  $input = <<<BLA
201 <?xml version="1.0"?>
202 <root xmlns="http://sabredav.org/ns">
203  <elem1 />
204 </root>
205 BLA;
206 
207  $reader = new Reader();
208  $reader->elementMap = [
209  '{http://sabredav.org/ns}elem1' => new \StdClass()
210  ];
211  $reader->xml($input);
212 
213  $reader->parse();
214  }

◆ testMappedElementCallBack()

Sabre\Xml\ReaderTest::testMappedElementCallBack ( )

testMappedElement

Definition at line 219 of file ReaderTest.php.

References $input, Sabre\VObject\$output, and $reader.

219  {
220 
221  $input = <<<BLA
222 <?xml version="1.0"?>
223 <root xmlns="http://sabredav.org/ns">
224  <elem1 />
225 </root>
226 BLA;
227 
228  $reader = new Reader();
229  $reader->elementMap = [
230  '{http://sabredav.org/ns}elem1' => function(Reader $reader) {
231  $reader->next();
232  return 'foobar';
233  }
234  ];
235  $reader->xml($input);
236 
237  $output = $reader->parse();
238 
239  $expected = [
240  'name' => '{http://sabredav.org/ns}root',
241  'value' => [
242  [
243  'name' => '{http://sabredav.org/ns}elem1',
244  'value' => 'foobar',
245  'attributes' => [],
246  ],
247  ],
248  'attributes' => [],
249 
250  ];
251 
252  $this->assertEquals($expected, $output);
253 
254  }

◆ testMappedElementCallBackNoNamespace()

Sabre\Xml\ReaderTest::testMappedElementCallBackNoNamespace ( )

testMappedElementCallBack

Definition at line 259 of file ReaderTest.php.

References $input, Sabre\VObject\$output, and $reader.

259  {
260 
261  $input = <<<BLA
262 <?xml version="1.0"?>
263 <root>
264  <elem1 />
265 </root>
266 BLA;
267 
268  $reader = new Reader();
269  $reader->elementMap = [
270  'elem1' => function(Reader $reader) {
271  $reader->next();
272  return 'foobar';
273  }
274  ];
275  $reader->xml($input);
276 
277  $output = $reader->parse();
278 
279  $expected = [
280  'name' => '{}root',
281  'value' => [
282  [
283  'name' => '{}elem1',
284  'value' => 'foobar',
285  'attributes' => [],
286  ],
287  ],
288  'attributes' => [],
289 
290  ];
291 
292  $this->assertEquals($expected, $output);
293 
294  }

◆ testParseGetElements()

Sabre\Xml\ReaderTest::testParseGetElements ( )

testParseInnerTree

Definition at line 487 of file ReaderTest.php.

References $input, Sabre\VObject\$output, $reader, Sabre\Xml\Reader\parse(), and Sabre\Xml\Reader\parseGetElements().

487  {
488 
489  $input = <<<BLA
490 <?xml version="1.0"?>
491 <root xmlns="http://sabredav.org/ns">
492  <elem1>
493  <elem1 />
494  </elem1>
495 </root>
496 BLA;
497 
498  $reader = new Reader();
499  $reader->elementMap = [
500  '{http://sabredav.org/ns}elem1' => function(Reader $reader) {
501 
502  $innerTree = $reader->parseGetElements(['{http://sabredav.org/ns}elem1' => function(Reader $reader) {
503  $reader->next();
504  return "foobar";
505  }]);
506 
507  return $innerTree;
508  }
509  ];
510  $reader->xml($input);
511 
512  $output = $reader->parse();
513 
514  $expected = [
515  'name' => '{http://sabredav.org/ns}root',
516  'value' => [
517  [
518  'name' => '{http://sabredav.org/ns}elem1',
519  'value' => [
520  [
521  'name' => '{http://sabredav.org/ns}elem1',
522  'value' => 'foobar',
523  'attributes' => [],
524  ]
525  ],
526  'attributes' => [],
527  ],
528  ],
529  'attributes' => [],
530 
531  ];
532 
533  $this->assertEquals($expected, $output);
534 
535  }
+ Here is the call graph for this function:

◆ testParseGetElementsNoElements()

Sabre\Xml\ReaderTest::testParseGetElementsNoElements ( )

testParseInnerTree

Definition at line 540 of file ReaderTest.php.

References $input, Sabre\VObject\$output, $reader, Sabre\Xml\Reader\parse(), and Sabre\Xml\Reader\parseGetElements().

540  {
541 
542  $input = <<<BLA
543 <?xml version="1.0"?>
544 <root xmlns="http://sabredav.org/ns">
545  <elem1>
546  hi
547  </elem1>
548 </root>
549 BLA;
550 
551  $reader = new Reader();
552  $reader->elementMap = [
553  '{http://sabredav.org/ns}elem1' => function(Reader $reader) {
554 
555  $innerTree = $reader->parseGetElements(['{http://sabredav.org/ns}elem1' => function(Reader $reader) {
556  $reader->next();
557  return "foobar";
558  }]);
559 
560  return $innerTree;
561  }
562  ];
563  $reader->xml($input);
564 
565  $output = $reader->parse();
566 
567  $expected = [
568  'name' => '{http://sabredav.org/ns}root',
569  'value' => [
570  [
571  'name' => '{http://sabredav.org/ns}elem1',
572  'value' => [],
573  'attributes' => [],
574  ],
575  ],
576  'attributes' => [],
577 
578  ];
579 
580  $this->assertEquals($expected, $output);
581 
582  }
+ Here is the call graph for this function:

◆ testParseInnerTree()

Sabre\Xml\ReaderTest::testParseInnerTree ( )

testMappedElement

Definition at line 434 of file ReaderTest.php.

434  {
435 
436  $input = <<<BLA
437 <?xml version="1.0"?>
438 <root xmlns="http://sabredav.org/ns">
439  <elem1>
440  <elem1 />
441  </elem1>
442 </root>
443 BLA;
444 
445  $reader = new Reader();
446  $reader->elementMap = [
447  '{http://sabredav.org/ns}elem1' => function(Reader $reader) {
448 
449  $innerTree = $reader->parseInnerTree(['{http://sabredav.org/ns}elem1' => function(Reader $reader) {
450  $reader->next();
451  return "foobar";
452  }]);
453 
454  return $innerTree;
455  }
456  ];
457  $reader->xml($input);
458 
459  $output = $reader->parse();
460 
461  $expected = [
462  'name' => '{http://sabredav.org/ns}root',
463  'value' => [
464  [
465  'name' => '{http://sabredav.org/ns}elem1',
466  'value' => [
467  [
468  'name' => '{http://sabredav.org/ns}elem1',
469  'value' => 'foobar',
470  'attributes' => [],
471  ]
472  ],
473  'attributes' => [],
474  ],
475  ],
476  'attributes' => [],
477 
478  ];
479 
480  $this->assertEquals($expected, $output);
481 
482  }

◆ testParseProblem()

Sabre\Xml\ReaderTest::testParseProblem ( )

Definition at line 338 of file ReaderTest.php.

References $input, Sabre\VObject\$output, $reader, and Sabre\Xml\LibXMLException\getErrors().

338  {
339 
340  $input = <<<BLA
341 <?xml version="1.0"?>
342 <root xmlns="http://sabredav.org/ns">
343 BLA;
344 
345  $reader = new Reader();
346  $reader->elementMap = [
347  '{http://sabredav.org/ns}elem1' => 'Sabre\\Xml\\Element\\Mock'
348  ];
349  $reader->xml($input);
350 
351  try {
352  $output = $reader->parse();
353  $this->fail('We expected a ParseException to be thrown');
354  } catch (LibXMLException $e) {
355 
356  $this->assertInternalType('array', $e->getErrors());
357 
358  }
359 
360  }
+ Here is the call graph for this function:

◆ testReadText()

Sabre\Xml\ReaderTest::testReadText ( )

testMappedElementCallBack

Definition at line 299 of file ReaderTest.php.

References $input, Sabre\VObject\$output, and $reader.

299  {
300 
301  $input = <<<BLA
302 <?xml version="1.0"?>
303 <root xmlns="http://sabredav.org/ns">
304  <elem1>
305  <elem2>hello </elem2>
306  <elem2>world</elem2>
307  </elem1>
308 </root>
309 BLA;
310 
311  $reader = new Reader();
312  $reader->elementMap = [
313  '{http://sabredav.org/ns}elem1' => function(Reader $reader) {
314  return $reader->readText();
315  }
316  ];
317  $reader->xml($input);
318 
319  $output = $reader->parse();
320 
321  $expected = [
322  'name' => '{http://sabredav.org/ns}root',
323  'value' => [
324  [
325  'name' => '{http://sabredav.org/ns}elem1',
326  'value' => 'hello world',
327  'attributes' => [],
328  ],
329  ],
330  'attributes' => [],
331 
332  ];
333 
334  $this->assertEquals($expected, $output);
335 
336  }

◆ testSimple()

Sabre\Xml\ReaderTest::testSimple ( )

Definition at line 49 of file ReaderTest.php.

References $input, Sabre\VObject\$output, and $reader.

49  {
50 
51  $input = <<<BLA
52 <?xml version="1.0"?>
53 <root xmlns="http://sabredav.org/ns">
54  <elem1 attr="val" />
55  <elem2>
56  <elem3>Hi!</elem3>
57  </elem2>
58 </root>
59 BLA;
60 
61  $reader = new Reader();
62  $reader->xml($input);
63 
64  $output = $reader->parse();
65 
66  $expected = [
67  'name' => '{http://sabredav.org/ns}root',
68  'value' => [
69  [
70  'name' => '{http://sabredav.org/ns}elem1',
71  'value' => null,
72  'attributes' => [
73  'attr' => 'val',
74  ],
75  ],
76  [
77  'name' => '{http://sabredav.org/ns}elem2',
78  'value' => [
79  [
80  'name' => '{http://sabredav.org/ns}elem3',
81  'value' => 'Hi!',
82  'attributes' => [],
83  ],
84  ],
85  'attributes' => [],
86  ],
87 
88  ],
89  'attributes' => [],
90 
91  ];
92 
93  $this->assertEquals($expected, $output);
94 
95  }

◆ testSimpleNamespacedAttribute()

Sabre\Xml\ReaderTest::testSimpleNamespacedAttribute ( )

Definition at line 129 of file ReaderTest.php.

References $input, Sabre\VObject\$output, and $reader.

129  {
130 
131  $input = <<<BLA
132 <?xml version="1.0"?>
133 <root xmlns="http://sabredav.org/ns" xmlns:foo="urn:foo">
134  <elem1 foo:attr="val" />
135 </root>
136 BLA;
137 
138  $reader = new Reader();
139  $reader->xml($input);
140 
141  $output = $reader->parse();
142 
143  $expected = [
144  'name' => '{http://sabredav.org/ns}root',
145  'value' => [
146  [
147  'name' => '{http://sabredav.org/ns}elem1',
148  'value' => null,
149  'attributes' => [
150  '{urn:foo}attr' => 'val',
151  ],
152  ],
153  ],
154  'attributes' => [],
155  ];
156 
157  $this->assertEquals($expected, $output);
158 
159  }

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