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

Public Member Functions

 testDeserializeValueObject ()
 
 testDeserializeValueObjectIgnoredElement ()
 
 testDeserializeValueObjectAutoArray ()
 
 testDeserializeValueObjectEmpty ()
 

Detailed Description

Definition at line 8 of file ValueObjectTest.php.

Member Function Documentation

◆ testDeserializeValueObject()

Sabre\XML\Deserializer\ValueObjectTest::testDeserializeValueObject ( )

Definition at line 10 of file ValueObjectTest.php.

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

10  {
11 
12  $input = <<<XML
13 <?xml version="1.0"?>
14 <foo xmlns="urn:foo">
15  <firstName>Harry</firstName>
16  <lastName>Turtle</lastName>
17 </foo>
18 XML;
19 
20  $reader = new Reader();
21  $reader->xml($input);
22  $reader->elementMap = [
23  '{urn:foo}foo' => function(Reader $reader) {
24  return valueObject($reader, 'Sabre\\Xml\\Deserializer\\TestVo', 'urn:foo');
25  }
26  ];
27 
28  $output = $reader->parse();
29 
30  $vo = new TestVo();
31  $vo->firstName = 'Harry';
32  $vo->lastName = 'Turtle';
33 
34  $expected = [
35  'name' => '{urn:foo}foo',
36  'value' => $vo,
37  'attributes' => []
38  ];
39 
40  $this->assertEquals(
41  $expected,
42  $output
43  );
44 
45  }
valueObject(Reader $reader, $className, $namespace)
The valueObject deserializer turns an xml element into a PHP object of a specific class...
Definition: functions.php:181
+ Here is the call graph for this function:

◆ testDeserializeValueObjectAutoArray()

Sabre\XML\Deserializer\ValueObjectTest::testDeserializeValueObjectAutoArray ( )

Definition at line 85 of file ValueObjectTest.php.

References $input, Sabre\VObject\$output, $reader, ILIAS\FileDelivery\http(), and Sabre\Xml\Deserializer\valueObject().

85  {
86 
87  $input = <<<XML
88 <?xml version="1.0"?>
89 <foo xmlns="urn:foo">
90  <firstName>Harry</firstName>
91  <lastName>Turtle</lastName>
92  <link>http://example.org/</link>
93  <link>http://example.net/</link>
94 </foo>
95 XML;
96 
97  $reader = new Reader();
98  $reader->xml($input);
99  $reader->elementMap = [
100  '{urn:foo}foo' => function(Reader $reader) {
101  return valueObject($reader, 'Sabre\\Xml\\Deserializer\\TestVo', 'urn:foo');
102  }
103  ];
104 
105  $output = $reader->parse();
106 
107  $vo = new TestVo();
108  $vo->firstName = 'Harry';
109  $vo->lastName = 'Turtle';
110  $vo->link = [
111  'http://example.org/',
112  'http://example.net/',
113  ];
114 
115 
116  $expected = [
117  'name' => '{urn:foo}foo',
118  'value' => $vo,
119  'attributes' => []
120  ];
121 
122  $this->assertEquals(
123  $expected,
124  $output
125  );
126 
127  }
static http()
Fetches the global http state from ILIAS.
valueObject(Reader $reader, $className, $namespace)
The valueObject deserializer turns an xml element into a PHP object of a specific class...
Definition: functions.php:181
+ Here is the call graph for this function:

◆ testDeserializeValueObjectEmpty()

Sabre\XML\Deserializer\ValueObjectTest::testDeserializeValueObjectEmpty ( )

Definition at line 128 of file ValueObjectTest.php.

References $input, and $reader.

128  {
129 
130  $input = <<<XML
131 <?xml version="1.0"?>
132 <foo xmlns="urn:foo" />
133 XML;
134 
135  $reader = new Reader();
136  $reader->xml($input);
137  $reader->elementMap = [
138  '{urn:foo}foo' => function(Reader $reader) {
139  return valueObject($reader, 'Sabre\\Xml\\Deserializer\\TestVo', 'urn:foo');
140  }
141  ];
142 
143  $output = $reader->parse();
144 
145  $vo = new TestVo();
146 
147  $expected = [
148  'name' => '{urn:foo}foo',
149  'value' => $vo,
150  'attributes' => []
151  ];
152 
153  $this->assertEquals(
154  $expected,
155  $output
156  );
157 
158  }
valueObject(Reader $reader, $className, $namespace)
The valueObject deserializer turns an xml element into a PHP object of a specific class...
Definition: functions.php:181

◆ testDeserializeValueObjectIgnoredElement()

Sabre\XML\Deserializer\ValueObjectTest::testDeserializeValueObjectIgnoredElement ( )

Definition at line 47 of file ValueObjectTest.php.

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

47  {
48 
49  $input = <<<XML
50 <?xml version="1.0"?>
51 <foo xmlns="urn:foo">
52  <firstName>Harry</firstName>
53  <lastName>Turtle</lastName>
54  <email>harry@example.org</email>
55 </foo>
56 XML;
57 
58  $reader = new Reader();
59  $reader->xml($input);
60  $reader->elementMap = [
61  '{urn:foo}foo' => function(Reader $reader) {
62  return valueObject($reader, 'Sabre\\Xml\\Deserializer\\TestVo', 'urn:foo');
63  }
64  ];
65 
66  $output = $reader->parse();
67 
68  $vo = new TestVo();
69  $vo->firstName = 'Harry';
70  $vo->lastName = 'Turtle';
71 
72  $expected = [
73  'name' => '{urn:foo}foo',
74  'value' => $vo,
75  'attributes' => []
76  ];
77 
78  $this->assertEquals(
79  $expected,
80  $output
81  );
82 
83  }
valueObject(Reader $reader, $className, $namespace)
The valueObject deserializer turns an xml element into a PHP object of a specific class...
Definition: functions.php:181
+ Here is the call graph for this function:

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