Skip to content

Commit

Permalink
Merge branch '6.0' into 6.1
Browse files Browse the repository at this point in the history
* 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()`
  • Loading branch information
chalasr committed Jul 27, 2022
2 parents 52943f3 + 92e4b59 commit 2e3b6a4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion HttpBrowser.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private function getBodyAndExtraHeaders(Request $request, array $headers): array
$fields = $request->getParameters();

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

return [$part->bodyToIterable(), $part->getPreparedHeaders()->toArray()];
}
Expand Down
8 changes: 6 additions & 2 deletions Tests/HttpBrowserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ public function testMultiPartRequestWithSingleFile()
->with('POST', 'http://example.com/', $this->callback(function ($options) {
$this->assertStringContainsString('Content-Type: multipart/form-data', implode('', $options['headers']));
$this->assertInstanceOf(\Generator::class, $options['body']);
$this->assertStringContainsString('my_file', implode('', iterator_to_array($options['body'])));
$values = implode('', iterator_to_array($options['body'], false));
$this->assertStringContainsString('name="foo[file]"', $values);
$this->assertStringContainsString('my_file', $values);
$this->assertStringContainsString('name="foo[bar]"', $values);
$this->assertStringContainsString('foo2', $values);

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

public function testMultiPartRequestWithNormalFlatArray()
Expand Down

0 comments on commit 2e3b6a4

Please sign in to comment.