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 @@ -1402,7 +1402,7 @@ private function addHttpClientSection(ArrayNodeDefinition $rootNode)
1402
1402
if (!\is_array ($ config )) {
1403
1403
return [];
1404
1404
}
1405
- if (!isset ($ config ['host ' ]) ) {
1405
+ if (!isset ($ config ['host ' ], $ config [ ' value ' ]) || \count ( $ config ) > 2 ) {
1406
1406
return $ config ;
1407
1407
}
1408
1408
@@ -1511,7 +1511,7 @@ private function addHttpClientSection(ArrayNodeDefinition $rootNode)
1511
1511
if (!\is_array ($ config )) {
1512
1512
return [];
1513
1513
}
1514
- if (!isset ($ config ['key ' ]) ) {
1514
+ if (!isset ($ config ['key ' ], $ config [ ' value ' ]) || \count ( $ config ) > 2 ) {
1515
1515
return $ config ;
1516
1516
}
1517
1517
@@ -1541,7 +1541,7 @@ private function addHttpClientSection(ArrayNodeDefinition $rootNode)
1541
1541
if (!\is_array ($ config )) {
1542
1542
return [];
1543
1543
}
1544
- if (!isset ($ config ['host ' ]) ) {
1544
+ if (!isset ($ config ['host ' ], $ config [ ' value ' ]) || \count ( $ config ) > 2 ) {
1545
1545
return $ config ;
1546
1546
}
1547
1547
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 @@ -1559,6 +1559,21 @@ public function testHttpClientOverrideDefaultOptions()
1559
1559
$ this ->assertSame ($ expected , $ container ->getDefinition ('foo ' )->getArgument (2 ));
1560
1560
}
1561
1561
1562
+ public function testHttpClientWithQueryParameterKey ()
1563
+ {
1564
+ $ container = $ this ->createContainerFromFile ('http_client_xml_key ' );
1565
+
1566
+ $ expected = [
1567
+ 'key ' => 'foo ' ,
1568
+ ];
1569
+ $ this ->assertSame ($ expected , $ container ->getDefinition ('foo ' )->getArgument (2 )['query ' ]);
1570
+
1571
+ $ expected = [
1572
+ 'host ' => '127.0.0.1 ' ,
1573
+ ];
1574
+ $ this ->assertSame ($ expected , $ container ->getDefinition ('foo ' )->getArgument (2 )['resolve ' ]);
1575
+ }
1576
+
1562
1577
public function testHttpClientFullDefaultOptions ()
1563
1578
{
1564
1579
$ container = $ this ->createContainerFromFile ('http_client_full_default_options ' );
You can’t perform that action at this time.
0 commit comments