ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
PropTest.php
Go to the documentation of this file.
1<?php
2
4
8
9class PropTest extends XmlTest {
10
12
13 $input = <<<XML
14<?xml version="1.0"?>
15<root xmlns="DAV:">
16 <foo>bar</foo>
17</root>
18XML;
19
20 $expected = [
21 '{DAV:}foo' => 'bar',
22 ];
23
24 $this->assertDecodeProp($input, $expected);
25
26 }
28
29 $input = <<<XML
30<?xml version="1.0"?>
31<root xmlns="DAV:" />
32XML;
33
34 $expected = [
35 ];
36
37 $this->assertDecodeProp($input, $expected);
38
39 }
41
42 $input = <<<XML
43<?xml version="1.0"?>
44<root xmlns="DAV:">
45 <foo><no>yes</no></foo>
46</root>
47XML;
48
49 $expected = [
50 '{DAV:}foo' => new Complex('<no xmlns="DAV:">yes</no>')
51 ];
52
53 $this->assertDecodeProp($input, $expected);
54
55 }
57
58 $input = <<<XML
59<?xml version="1.0"?>
60<root xmlns="DAV:">
61 <foo><href>/hello</href></foo>
62</root>
63XML;
64
65 $expected = [
66 '{DAV:}foo' => new Href('/hello', false)
67 ];
68
69 $elementMap = [
70 '{DAV:}foo' => 'Sabre\DAV\Xml\Property\Href'
71 ];
72
73 $this->assertDecodeProp($input, $expected, $elementMap);
74
75 }
77
78 $input = <<<XML
79<?xml version="1.0"?>
80<root xmlns="DAV:">
81 <foo>blabla</foo>
82</root>
83XML;
84
85 $expected = [
86 '{DAV:}foo' => 'zim',
87 ];
88
89 $elementMap = [
90 '{DAV:}foo' => function($reader) {
91 $reader->next();
92 return 'zim';
93 }
94 ];
95
96 $this->assertDecodeProp($input, $expected, $elementMap);
97
98 }
99
104
105 $input = <<<XML
106<?xml version="1.0"?>
107<root xmlns="DAV:">
108 <foo>blabla</foo>
109</root>
110XML;
111
112 $expected = [];
113
114 $elementMap = [
115 '{DAV:}foo' => 'idk?',
116 ];
117
118 $this->assertDecodeProp($input, $expected, $elementMap);
119
120 }
121
126
127 $input = <<<XML
128<?xml version="1.0"?>
129<root xmlns="DAV:">
130 <foo>blabla</foo>
131</root>
132XML;
133
134 $expected = [];
135
136 $elementMap = [
137 '{DAV:}foo' => new \StdClass(),
138 ];
139
140 $this->assertDecodeProp($input, $expected, $elementMap);
141
142 }
143
144 function assertDecodeProp($input, array $expected, array $elementMap = []) {
145
146 $elementMap['{DAV:}root'] = 'Sabre\DAV\Xml\Element\Prop';
147
148 $result = $this->parse($input, $elementMap);
149 $this->assertInternalType('array', $result);
150 $this->assertEquals($expected, $result['value']);
151
152 }
153
154}
$result
An exception for terminatinating execution or to throw for unit testing.
assertDecodeProp($input, array $expected, array $elementMap=[])
Definition: PropTest.php:144
testDeserializeCustomBad()
@expectedException \LogicException
Definition: PropTest.php:103
testDeserializeCustomBadObj()
@expectedException \LogicException
Definition: PropTest.php:125
This class represents a 'complex' property that didn't have a default decoder.
Definition: Complex.php:18
Href property.
Definition: Href.php:26
parse($xml, array $elementMap=[])
Definition: XmlTest.php:26