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 55a5b86

Browse filesBrowse files
committed
fix tests
The data provider was depending on the openssl extension being present.
1 parent 4a9c2e8 commit 55a5b86
Copy full SHA for 55a5b86

File tree

Expand file treeCollapse file tree

1 file changed

+39
-6
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+39
-6
lines changed

‎src/Symfony/Component/HttpClient/Tests/HttpClientTraitTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpClient/Tests/HttpClientTraitTest.php
+39-6Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,11 @@ public function testNormalizeBodyMultipart()
116116
* @group network
117117
*
118118
* @requires extension openssl
119-
*
120-
* @dataProvider provideNormalizeBodyMultipartForwardStream
121119
*/
122-
public function testNormalizeBodyMultipartForwardStream($stream)
120+
public function testNormalizeBodyMultipartForwardStreamUsingStreamWrapper($stream)
123121
{
122+
$stream = fopen('https://github.githubassets.com/images/icons/emoji/unicode/1f44d.png', 'r');
123+
124124
$body = [
125125
'logo' => $stream,
126126
];
@@ -151,10 +151,43 @@ public function testNormalizeBodyMultipartForwardStream($stream)
151151
$this->assertStringMatchesFormat($expected, $result);
152152
}
153153

154-
public static function provideNormalizeBodyMultipartForwardStream()
154+
/**
155+
* @group network
156+
*
157+
* @requires extension openssl
158+
*/
159+
public function testNormalizeBodyMultipartForwardStreamWithHttpClient()
155160
{
156-
yield 'native' => [fopen('https://github.githubassets.com/images/icons/emoji/unicode/1f44d.png', 'r')];
157-
yield 'symfony' => [HttpClient::create()->request('GET', 'https://github.githubassets.com/images/icons/emoji/unicode/1f44d.png')->toStream()];
161+
$stream = HttpClient::create()->request('GET', 'https://github.githubassets.com/images/icons/emoji/unicode/1f44d.png')->toStream();
162+
163+
$body = [
164+
'logo' => $stream,
165+
];
166+
167+
$headers = [];
168+
$body = self::normalizeBody($body, $headers);
169+
170+
$result = '';
171+
while ('' !== $data = $body(self::$CHUNK_SIZE)) {
172+
$result .= $data;
173+
}
174+
175+
$this->assertSame(1, preg_match('/^Content-Type: multipart\/form-data; boundary=(?<boundary>.+)$/', $headers['content-type'][0], $matches));
176+
$this->assertSame('Content-Length: 3086', $headers['content-length'][0]);
177+
$this->assertSame(3086, \strlen($result));
178+
179+
$expected = <<<EOF
180+
--{$matches['boundary']}
181+
Content-Disposition: form-data; name="logo"; filename="1f44d.png"
182+
Content-Type: image/png
183+
184+
%A
185+
--{$matches['boundary']}--
186+
187+
EOF;
188+
$expected = str_replace("\n", "\r\n", $expected);
189+
190+
$this->assertStringMatchesFormat($expected, $result);
158191
}
159192

160193
/**

0 commit comments

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