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

Public Member Functions

 testKeyValue ()
 
 testKeyValueLoop ()
 

Detailed Description

Definition at line 8 of file KeyValueTest.php.

Member Function Documentation

◆ testKeyValue()

Sabre\Xml\Deserializer\KeyValueTest::testKeyValue ( )

Definition at line 10 of file KeyValueTest.php.

References $input, Sabre\VObject\$output, $reader, and Sabre\Xml\Deserializer\keyValue().

10  {
11 
12  $input = <<<BLA
13 <?xml version="1.0"?>
14 <root xmlns="http://sabredav.org/ns">
15  <struct>
16  <elem1 />
17  <elem2>hi</elem2>
18  <elem3 xmlns="http://sabredav.org/another-ns">
19  <elem4>foo</elem4>
20  <elem5>foo &amp; bar</elem5>
21  </elem3>
22  </struct>
23 </root>
24 BLA;
25 
26  $reader = new Reader();
27  $reader->elementMap = [
28  '{http://sabredav.org/ns}struct' => function(Reader $reader) {
29  return keyValue($reader, 'http://sabredav.org/ns');
30  }
31  ];
32  $reader->xml($input);
33  $output = $reader->parse();
34 
35  $this->assertEquals([
36  'name' => '{http://sabredav.org/ns}root',
37  'value' => [
38  [
39  'name' => '{http://sabredav.org/ns}struct',
40  'value' => [
41  'elem1' => null,
42  'elem2' => 'hi',
43  '{http://sabredav.org/another-ns}elem3' => [
44  [
45  'name' => '{http://sabredav.org/another-ns}elem4',
46  'value' => 'foo',
47  'attributes' => [],
48  ],
49  [
50  'name' => '{http://sabredav.org/another-ns}elem5',
51  'value' => 'foo & bar',
52  'attributes' => [],
53  ],
54  ]
55  ],
56  'attributes' => [],
57  ]
58  ],
59  'attributes' => [],
60  ], $output);
61  }
keyValue(Reader $reader, $namespace=null)
This class provides a number of &#39;deserializer&#39; helper functions.
Definition: functions.php:61
+ Here is the call graph for this function:

◆ testKeyValueLoop()

Sabre\Xml\Deserializer\KeyValueTest::testKeyValueLoop ( )

This bug is a weird one, because it triggers an infinite loop, but only if the XML document is a certain size (in bytes). Removing one or two characters from the xml body here cause the infinite loop to not get triggered, so to properly test this bug (Issue #94), don't change the XML body.

Definition at line 66 of file KeyValueTest.php.

References $reader, and Sabre\Xml\Deserializer\keyValue().

66  {
67 
75  $invalid_xml = '
76  <foo ft="PRNTING" Ppt="YES" AutoClose="YES" SkipUnverified="NO" Test="NO">
77  <Package ID="1">
78  <MailClass>NONE</MailClass>
79  <PackageType>ENVELOPE</PackageType>
80  <WeightOz>1</WeightOz>
81  <FleetType>DC</FleetType>
82  <Package ID="2">
83  <MailClass>NONE</MailClass>
84  <PackageType>ENVELOPE</PackageType>
85  <WeightOz>1</WeightOz>
86  <FleetType>DC/FleetType>
87  </Package>
88  </foo>';
89  $reader = new Reader();
90 
91  $reader->xml($invalid_xml);
92  $reader->elementMap = [
93 
94  '{}Package' => function($reader) {
95  $recipient = [];
96  // Borrowing a parser from the KeyValue class.
97  $keyValue = keyValue($reader);
98 
99  if (isset($keyValue['{}WeightOz'])){
100  $recipient['referenceId'] = $keyValue['{}WeightOz'];
101  }
102 
103  return $recipient;
104  },
105  ];
106 
107  $reader->parse();
108 
109 
110  }
keyValue(Reader $reader, $namespace=null)
This class provides a number of &#39;deserializer&#39; helper functions.
Definition: functions.php:61
+ Here is the call graph for this function:

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