Skip to content

Commit 217cfdb

Browse files
committed
minor #11233 [Serializer] Added a test for decoding xml with whitespaces (florianv)
This PR was merged into the 2.6-dev branch. Discussion ---------- [Serializer] Added a test for decoding xml with whitespaces | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | The PR symfony/symfony@466a3d7 introduced a BC break because white spaces were previously decoded as text nodes. So this PR reverts it and adds a context option to configure it. Commits ------- f5bf45e [Serializer] Added a test for decoding xml with whitespaces
2 parents da611c7 + cfa1bab commit 217cfdb

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

Tests/Encoder/XmlEncoderTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,29 @@ public function testDecodeArray()
312312
$this->assertEquals($expected, $this->encoder->decode($source, 'xml'));
313313
}
314314

315+
public function testDecodeIgnoreWhiteSpace()
316+
{
317+
$source = <<<XML
318+
<?xml version="1.0"?>
319+
<people>
320+
<person>
321+
<firstname>Benjamin</firstname>
322+
<lastname>Alexandre</lastname>
323+
</person>
324+
<person>
325+
<firstname>Damien</firstname>
326+
<lastname>Clay</lastname>
327+
</person>
328+
</people>
329+
XML;
330+
$expected = array('person' => array(
331+
array('firstname' => 'Benjamin', 'lastname' => 'Alexandre'),
332+
array('firstname' => 'Damien', 'lastname' => 'Clay')
333+
));
334+
335+
$this->assertEquals($expected, $this->encoder->decode($source, 'xml'));
336+
}
337+
315338
public function testDecodeWithoutItemHash()
316339
{
317340
$obj = new ScalarDummy();

0 commit comments

Comments
 (0)