diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index 4263acc5dd19..105695c963d9 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -1402,7 +1402,7 @@ private function addHttpClientSection(ArrayNodeDefinition $rootNode) if (!\is_array($config)) { return []; } - if (!isset($config['host'])) { + if (!isset($config['host'], $config['value']) || \count($config) > 2) { return $config; } @@ -1511,7 +1511,7 @@ private function addHttpClientSection(ArrayNodeDefinition $rootNode) if (!\is_array($config)) { return []; } - if (!isset($config['key'])) { + if (!isset($config['key'], $config['value']) || \count($config) > 2) { return $config; } @@ -1541,7 +1541,7 @@ private function addHttpClientSection(ArrayNodeDefinition $rootNode) if (!\is_array($config)) { return []; } - if (!isset($config['host'])) { + if (!isset($config['host'], $config['value']) || \count($config) > 2) { return $config; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/http_client_xml_key.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/http_client_xml_key.php new file mode 100644 index 000000000000..64778c61561b --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/http_client_xml_key.php @@ -0,0 +1,22 @@ +loadFromExtension('framework', [ + 'http_client' => [ + 'default_options' => [ + 'resolve' => [ + 'host' => '127.0.0.1', + ], + ], + 'scoped_clients' => [ + 'foo' => [ + 'base_uri' => 'http://example.com', + 'query' => [ + 'key' => 'foo', + ], + 'resolve' => [ + 'host' => '127.0.0.1', + ], + ], + ], + ], +]); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/http_client_xml_key.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/http_client_xml_key.xml new file mode 100644 index 000000000000..95ef0737f8a0 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/http_client_xml_key.xml @@ -0,0 +1,19 @@ + + + + + + + 127.0.0.1 + + + foo + 127.0.0.1 + + + + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/http_client_xml_key.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/http_client_xml_key.yml new file mode 100644 index 000000000000..dc87555a901a --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/http_client_xml_key.yml @@ -0,0 +1,12 @@ +framework: + http_client: + default_options: + resolve: + host: 127.0.0.1 + scoped_clients: + foo: + base_uri: http://example.com + query: + key: foo + resolve: + host: 127.0.0.1 diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index f289c6df469d..b65ab9e011f2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -1559,6 +1559,21 @@ public function testHttpClientOverrideDefaultOptions() $this->assertSame($expected, $container->getDefinition('foo')->getArgument(2)); } + public function testHttpClientWithQueryParameterKey() + { + $container = $this->createContainerFromFile('http_client_xml_key'); + + $expected = [ + 'key' => 'foo', + ]; + $this->assertSame($expected, $container->getDefinition('foo')->getArgument(2)['query']); + + $expected = [ + 'host' => '127.0.0.1', + ]; + $this->assertSame($expected, $container->getDefinition('foo')->getArgument(2)['resolve']); + } + public function testHttpClientFullDefaultOptions() { $container = $this->createContainerFromFile('http_client_full_default_options');