File tree Expand file tree Collapse file tree 5 files changed +71
-3
lines changed
Tests/DependencyInjection Expand file tree Collapse file tree 5 files changed +71
-3
lines changed Original file line number Diff line number Diff line change @@ -1279,7 +1279,7 @@ private function addHttpClientSection(ArrayNodeDefinition $rootNode)
1279
1279
if (!\is_array ($ config )) {
1280
1280
return [];
1281
1281
}
1282
- if (!isset ($ config ['host ' ]) ) {
1282
+ if (!isset ($ config ['host ' ], $ config [ ' value ' ]) || \count ( $ config ) > 2 ) {
1283
1283
return $ config ;
1284
1284
}
1285
1285
@@ -1388,7 +1388,7 @@ private function addHttpClientSection(ArrayNodeDefinition $rootNode)
1388
1388
if (!\is_array ($ config )) {
1389
1389
return [];
1390
1390
}
1391
- if (!isset ($ config ['key ' ]) ) {
1391
+ if (!isset ($ config ['key ' ], $ config [ ' value ' ]) || \count ( $ config ) > 2 ) {
1392
1392
return $ config ;
1393
1393
}
1394
1394
@@ -1418,7 +1418,7 @@ private function addHttpClientSection(ArrayNodeDefinition $rootNode)
1418
1418
if (!\is_array ($ config )) {
1419
1419
return [];
1420
1420
}
1421
- if (!isset ($ config ['host ' ]) ) {
1421
+ if (!isset ($ config ['host ' ], $ config [ ' value ' ]) || \count ( $ config ) > 2 ) {
1422
1422
return $ config ;
1423
1423
}
1424
1424
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ $ container ->loadFromExtension ('framework ' , [
4
+ 'http_client ' => [
5
+ 'default_options ' => [
6
+ 'resolve ' => [
7
+ 'host ' => '127.0.0.1 ' ,
8
+ ],
9
+ ],
10
+ 'scoped_clients ' => [
11
+ 'foo ' => [
12
+ 'base_uri ' => 'http://example.com ' ,
13
+ 'query ' => [
14
+ 'key ' => 'foo ' ,
15
+ ],
16
+ 'resolve ' => [
17
+ 'host ' => '127.0.0.1 ' ,
18
+ ],
19
+ ],
20
+ ],
21
+ ],
22
+ ]);
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" utf-8" ?>
2
+ <container xmlns =" http://symfony.com/schema/dic/services"
3
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
4
+ xmlns : framework =" http://symfony.com/schema/dic/symfony"
5
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
6
+ http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
7
+
8
+ <framework : config >
9
+ <framework : http-client >
10
+ <framework : default-options >
11
+ <framework : resolve host =" host" >127.0.0.1</framework : resolve >
12
+ </framework : default-options >
13
+ <framework : scoped-client name =" foo" base-uri =" http://example.com" >
14
+ <framework : query key =" key" >foo</framework : query >
15
+ <framework : resolve host =" host" >127.0.0.1</framework : resolve >
16
+ </framework : scoped-client >
17
+ </framework : http-client >
18
+ </framework : config >
19
+ </container >
Original file line number Diff line number Diff line change
1
+ framework :
2
+ http_client :
3
+ default_options :
4
+ resolve :
5
+ host : 127.0.0.1
6
+ scoped_clients :
7
+ foo :
8
+ base_uri : http://example.com
9
+ query :
10
+ key : foo
11
+ resolve :
12
+ host : 127.0.0.1
Original file line number Diff line number Diff line change @@ -1360,6 +1360,21 @@ public function testHttpClientOverrideDefaultOptions()
1360
1360
$ this ->assertSame ($ expected , $ container ->getDefinition ('foo ' )->getArgument (2 ));
1361
1361
}
1362
1362
1363
+ public function testHttpClientWithQueryParameterKey ()
1364
+ {
1365
+ $ container = $ this ->createContainerFromFile ('http_client_xml_key ' );
1366
+
1367
+ $ expected = [
1368
+ 'key ' => 'foo ' ,
1369
+ ];
1370
+ $ this ->assertSame ($ expected , $ container ->getDefinition ('foo ' )->getArgument (2 )['query ' ]);
1371
+
1372
+ $ expected = [
1373
+ 'host ' => '127.0.0.1 ' ,
1374
+ ];
1375
+ $ this ->assertSame ($ expected , $ container ->getDefinition ('foo ' )->getArgument (2 )['resolve ' ]);
1376
+ }
1377
+
1363
1378
public function testHttpClientFullDefaultOptions ()
1364
1379
{
1365
1380
$ container = $ this ->createContainerFromFile ('http_client_full_default_options ' );
You can’t perform that action at this time.
0 commit comments