Skip to content

Commit

Permalink
Merge branch '4.4' into 5.4
Browse files Browse the repository at this point in the history
* 4.4:
  [BrowserKit] Merge fields and files recursively if they are multidimensional array
  [Serializer] Fix XmlEncoder encoding attribute false
  • Loading branch information
chalasr committed Jul 27, 2022
2 parents 447b7ef + 2f4e11f commit 443f8c3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Encoder/XmlEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,9 @@ private function buildXml(\DOMNode $parentNode, $data, string $format, array $co
if (!\is_scalar($data)) {
$data = $this->serializer->normalize($data, $format, $context);
}
if (\is_bool($data)) {
$data = (int) $data;
}
$parentNode->setAttribute($attributeName, $data);
} elseif ('#' === $key) {
$append = $this->selectNodeType($parentNode, $data, $format, $context);
Expand Down
8 changes: 8 additions & 0 deletions Tests/Encoder/XmlEncoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ public function testAttributes()
'föo_bär' => 'a',
'Bar' => [1, 2, 3],
'a' => 'b',
'scalars' => [
'@bool-true' => true,
'@bool-false' => false,
'@int' => 3,
'@float' => 3.4,
'@sring' => 'a',
],
];
$expected = '<?xml version="1.0"?>'."\n".
'<response>'.
Expand All @@ -106,6 +113,7 @@ public function testAttributes()
'<Bar>2</Bar>'.
'<Bar>3</Bar>'.
'<a>b</a>'.
'<scalars bool-true="1" bool-false="0" int="3" float="3.4" sring="a"/>'.
'</response>'."\n";
$this->assertEquals($expected, $this->encoder->encode($obj, 'xml'));
}
Expand Down

0 comments on commit 443f8c3

Please sign in to comment.