Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2a4125f

Browse filesBrowse files
committed
Merge branch '4.4' into 5.4
* 4.4: [BrowserKit] Merge fields and files recursively if they are multidimensional array [Serializer] Fix XmlEncoder encoding attribute false
2 parents c02b704 + e3e2b32 commit 2a4125f
Copy full SHA for 2a4125f

File tree

Expand file treeCollapse file tree

4 files changed

+18
-3
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+18
-3
lines changed

‎src/Symfony/Component/BrowserKit/HttpBrowser.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/BrowserKit/HttpBrowser.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ private function getBodyAndExtraHeaders(Request $request, array $headers): array
8282
$fields = $request->getParameters();
8383

8484
if ($uploadedFiles = $this->getUploadedFiles($request->getFiles())) {
85-
$part = new FormDataPart(array_merge($fields, $uploadedFiles));
85+
$part = new FormDataPart(array_replace_recursive($fields, $uploadedFiles));
8686

8787
return [$part->bodyToIterable(), $part->getPreparedHeaders()->toArray()];
8888
}

‎src/Symfony/Component/BrowserKit/Tests/HttpBrowserTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/BrowserKit/Tests/HttpBrowserTest.php
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,11 @@ public function testMultiPartRequestWithSingleFile()
9494
->with('POST', 'http://example.com/', $this->callback(function ($options) {
9595
$this->assertStringContainsString('Content-Type: multipart/form-data', implode('', $options['headers']));
9696
$this->assertInstanceOf(\Generator::class, $options['body']);
97-
$this->assertStringContainsString('my_file', implode('', iterator_to_array($options['body'])));
97+
$values = implode('', iterator_to_array($options['body'], false));
98+
$this->assertStringContainsString('name="foo[file]"', $values);
99+
$this->assertStringContainsString('my_file', $values);
100+
$this->assertStringContainsString('name="foo[bar]"', $values);
101+
$this->assertStringContainsString('foo2', $values);
98102

99103
return true;
100104
}))
@@ -103,7 +107,7 @@ public function testMultiPartRequestWithSingleFile()
103107
$browser = new HttpBrowser($client);
104108
$path = tempnam(sys_get_temp_dir(), 'http');
105109
file_put_contents($path, 'my_file');
106-
$browser->request('POST', 'http://example.com/', [], ['file' => ['tmp_name' => $path, 'name' => 'foo']]);
110+
$browser->request('POST', 'http://example.com/', ['foo' => ['bar' => 'foo2']], ['foo' => ['file' => ['tmp_name' => $path, 'name' => 'foo']]]);
107111
}
108112

109113
public function testMultiPartRequestWithNormalFlatArray()

‎src/Symfony/Component/Serializer/Encoder/XmlEncoder.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Encoder/XmlEncoder.php
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,9 @@ private function buildXml(\DOMNode $parentNode, $data, string $format, array $co
372372
if (!\is_scalar($data)) {
373373
$data = $this->serializer->normalize($data, $format, $context);
374374
}
375+
if (\is_bool($data)) {
376+
$data = (int) $data;
377+
}
375378
$parentNode->setAttribute($attributeName, $data);
376379
} elseif ('#' === $key) {
377380
$append = $this->selectNodeType($parentNode, $data, $format, $context);

‎src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ public function testAttributes()
9696
'föo_bär' => 'a',
9797
'Bar' => [1, 2, 3],
9898
'a' => 'b',
99+
'scalars' => [
100+
'@bool-true' => true,
101+
'@bool-false' => false,
102+
'@int' => 3,
103+
'@float' => 3.4,
104+
'@sring' => 'a',
105+
],
99106
];
100107
$expected = '<?xml version="1.0"?>'."\n".
101108
'<response>'.
@@ -106,6 +113,7 @@ public function testAttributes()
106113
'<Bar>2</Bar>'.
107114
'<Bar>3</Bar>'.
108115
'<a>b</a>'.
116+
'<scalars bool-true="1" bool-false="0" int="3" float="3.4" sring="a"/>'.
109117
'</response>'."\n";
110118
$this->assertEquals($expected, $this->encoder->encode($obj, 'xml'));
111119
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.