comparison vendor/symfony/var-dumper/Tests/Caster/XmlReaderCasterTest.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children 129ea1e6d783
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Symfony\Component\VarDumper\Tests\Caster;
13
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\VarDumper\Test\VarDumperTestTrait;
16
17 /**
18 * @author Baptiste Clavié <clavie.b@gmail.com>
19 */
20 class XmlReaderCasterTest extends TestCase
21 {
22 use VarDumperTestTrait;
23
24 /** @var \XmlReader */
25 private $reader;
26
27 protected function setUp()
28 {
29 $this->reader = new \XmlReader();
30 $this->reader->open(__DIR__.'/../Fixtures/xml_reader.xml');
31 }
32
33 protected function tearDown()
34 {
35 $this->reader->close();
36 }
37
38 public function testParserProperty()
39 {
40 $this->reader->setParserProperty(\XMLReader::SUBST_ENTITIES, true);
41
42 $expectedDump = <<<'EODUMP'
43 XMLReader {
44 +nodeType: NONE
45 parserProperties: {
46 SUBST_ENTITIES: true
47 …3
48 }
49 …12
50 }
51 EODUMP;
52
53 $this->assertDumpMatchesFormat($expectedDump, $this->reader);
54 }
55
56 /**
57 * @dataProvider provideNodes
58 */
59 public function testNodes($seek, $expectedDump)
60 {
61 while ($seek--) {
62 $this->reader->read();
63 }
64 $this->assertDumpMatchesFormat($expectedDump, $this->reader);
65 }
66
67 public function provideNodes()
68 {
69 return array(
70 array(0, <<<'EODUMP'
71 XMLReader {
72 +nodeType: NONE
73 …13
74 }
75 EODUMP
76 ),
77 array(1, <<<'EODUMP'
78 XMLReader {
79 +localName: "foo"
80 +nodeType: ELEMENT
81 +baseURI: "%sxml_reader.xml"
82 …11
83 }
84 EODUMP
85 ),
86 array(2, <<<'EODUMP'
87 XMLReader {
88 +localName: "#text"
89 +nodeType: SIGNIFICANT_WHITESPACE
90 +depth: 1
91 +value: """
92 \n
93
94 """
95 +baseURI: "%sxml_reader.xml"
96 …9
97 }
98 EODUMP
99 ),
100 array(3, <<<'EODUMP'
101 XMLReader {
102 +localName: "bar"
103 +nodeType: ELEMENT
104 +depth: 1
105 +baseURI: "%sxml_reader.xml"
106 …10
107 }
108 EODUMP
109 ),
110 array(4, <<<'EODUMP'
111 XMLReader {
112 +localName: "bar"
113 +nodeType: END_ELEMENT
114 +depth: 1
115 +baseURI: "%sxml_reader.xml"
116 …10
117 }
118 EODUMP
119 ),
120 array(6, <<<'EODUMP'
121 XMLReader {
122 +localName: "bar"
123 +nodeType: ELEMENT
124 +depth: 1
125 +isEmptyElement: true
126 +baseURI: "%sxml_reader.xml"
127 …9
128 }
129 EODUMP
130 ),
131 array(9, <<<'EODUMP'
132 XMLReader {
133 +localName: "#text"
134 +nodeType: TEXT
135 +depth: 2
136 +value: "With text"
137 +baseURI: "%sxml_reader.xml"
138 …9
139 }
140 EODUMP
141 ),
142 array(12, <<<'EODUMP'
143 XMLReader {
144 +localName: "bar"
145 +nodeType: ELEMENT
146 +depth: 1
147 +attributeCount: 2
148 +baseURI: "%sxml_reader.xml"
149 …9
150 }
151 EODUMP
152 ),
153 array(13, <<<'EODUMP'
154 XMLReader {
155 +localName: "bar"
156 +nodeType: END_ELEMENT
157 +depth: 1
158 +baseURI: "%sxml_reader.xml"
159 …10
160 }
161 EODUMP
162 ),
163 array(15, <<<'EODUMP'
164 XMLReader {
165 +localName: "bar"
166 +nodeType: ELEMENT
167 +depth: 1
168 +attributeCount: 1
169 +baseURI: "%sxml_reader.xml"
170 …9
171 }
172 EODUMP
173 ),
174 array(16, <<<'EODUMP'
175 XMLReader {
176 +localName: "#text"
177 +nodeType: SIGNIFICANT_WHITESPACE
178 +depth: 2
179 +value: """
180 \n
181
182 """
183 +baseURI: "%sxml_reader.xml"
184 …9
185 }
186 EODUMP
187 ),
188 array(17, <<<'EODUMP'
189 XMLReader {
190 +localName: "baz"
191 +prefix: "baz"
192 +nodeType: ELEMENT
193 +depth: 2
194 +namespaceURI: "http://symfony.com"
195 +baseURI: "%sxml_reader.xml"
196 …8
197 }
198 EODUMP
199 ),
200 array(18, <<<'EODUMP'
201 XMLReader {
202 +localName: "baz"
203 +prefix: "baz"
204 +nodeType: END_ELEMENT
205 +depth: 2
206 +namespaceURI: "http://symfony.com"
207 +baseURI: "%sxml_reader.xml"
208 …8
209 }
210 EODUMP
211 ),
212 array(19, <<<'EODUMP'
213 XMLReader {
214 +localName: "#text"
215 +nodeType: SIGNIFICANT_WHITESPACE
216 +depth: 2
217 +value: """
218 \n
219
220 """
221 +baseURI: "%sxml_reader.xml"
222 …9
223 }
224 EODUMP
225 ),
226 array(21, <<<'EODUMP'
227 XMLReader {
228 +localName: "#text"
229 +nodeType: SIGNIFICANT_WHITESPACE
230 +depth: 1
231 +value: "\n"
232 +baseURI: "%sxml_reader.xml"
233 …9
234 }
235 EODUMP
236 ),
237 array(22, <<<'EODUMP'
238 XMLReader {
239 +localName: "foo"
240 +nodeType: END_ELEMENT
241 +baseURI: "%sxml_reader.xml"
242 …11
243 }
244 EODUMP
245 ),
246 );
247 }
248 }