Skip to content

Commit 2e3b6a4

Browse files
committed
Merge branch '6.0' into 6.1
* 6.0: [BrowserKit] Merge fields and files recursively if they are multidimensional array [String] Fix `width` method in `AbstractUnicodeString` [Mailer] Add a comment to avoid the same wrong PR over and over again [Serializer] Fix XmlEncoder encoding attribute false [HttpFoundation] Fix `\Stringable` support in `InputBag::get()`
2 parents 52943f3 + 92e4b59 commit 2e3b6a4

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

HttpBrowser.php

+1-1
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
}

Tests/HttpBrowserTest.php

+6-2
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()

0 commit comments

Comments
 (0)