Skip to content

Commit 7ac0d8d

Browse files
Merge branch '4.4' into 5.4
* 4.4: [Serializer] Fix passing null to str_contains() [DependencyInjection] Don't reset env placeholders during compilation [HttpClient] Fix overriding default options with null [DependencyInjection] Clarify that using expressions in parameters is not allowed [GHA] Cancel running CI jobs when a PR is updated [Validator] Improve tests for the Image and File constraints [Validator][Tests] Fix AssertingContextualValidator not throwing on remaining expectations
2 parents 1badd3d + 68e5283 commit 7ac0d8d

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

HttpClientTrait.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,7 @@ private static function mergeDefaultOptions(array $options, array $defaultOption
199199
// Option "query" is never inherited from defaults
200200
$options['query'] = $options['query'] ?? [];
201201

202-
foreach ($defaultOptions as $k => $v) {
203-
if ('normalized_headers' !== $k && !isset($options[$k])) {
204-
$options[$k] = $v;
205-
}
206-
}
202+
$options += $defaultOptions;
207203

208204
if (isset($defaultOptions['extra'])) {
209205
$options['extra'] += $defaultOptions['extra'];

Tests/MockHttpClientTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\HttpClient\Chunk\DataChunk;
1515
use Symfony\Component\HttpClient\Chunk\ErrorChunk;
1616
use Symfony\Component\HttpClient\Chunk\FirstChunk;
17+
use Symfony\Component\HttpClient\Exception\InvalidArgumentException;
1718
use Symfony\Component\HttpClient\Exception\TransportException;
1819
use Symfony\Component\HttpClient\MockHttpClient;
1920
use Symfony\Component\HttpClient\NativeHttpClient;
@@ -271,6 +272,15 @@ public function testThrowExceptionInBodyGenerator()
271272
$this->assertSame('bar ccc', $chunks[2]->getError());
272273
}
273274

275+
public function testMergeDefaultOptions()
276+
{
277+
$mockHttpClient = new MockHttpClient(null, 'https://example.com');
278+
279+
$this->expectException(InvalidArgumentException::class);
280+
$this->expectExceptionMessage('Invalid URL: scheme is missing');
281+
$mockHttpClient->request('GET', '/foo', ['base_uri' => null]);
282+
}
283+
274284
protected function getHttpClient(string $testCase): HttpClientInterface
275285
{
276286
$responses = [];

0 commit comments

Comments
 (0)