diff --git a/CHANGELOG.md b/CHANGELOG.md index d45cc71f..751d3c81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ The change log describes what is "Added", "Removed", "Changed" or "Fixed" between each release. +### Fixed + +- Fix to pass only allowed options to the `ContentTypePlugin`. + ## 1.15.1 - 2019-04-12 ### Fixed diff --git a/src/DependencyInjection/HttplugExtension.php b/src/DependencyInjection/HttplugExtension.php index b48296f4..78595c27 100644 --- a/src/DependencyInjection/HttplugExtension.php +++ b/src/DependencyInjection/HttplugExtension.php @@ -270,7 +270,9 @@ private function configurePluginByName($name, Definition $definition, array $con break; case 'content_type': + unset($config['enabled']); $definition->replaceArgument(0, $config); + break; case 'header_append': diff --git a/tests/Resources/Fixtures/config/full.php b/tests/Resources/Fixtures/config/full.php index 0dc4fc7c..399b1d25 100644 --- a/tests/Resources/Fixtures/config/full.php +++ b/tests/Resources/Fixtures/config/full.php @@ -35,6 +35,11 @@ 'uri' => 'http://localhost', ], ], + [ + 'content_type' => [ + 'skip_detection' => true, + ], + ], [ 'header_set' => [ 'headers' => [ diff --git a/tests/Resources/Fixtures/config/full.xml b/tests/Resources/Fixtures/config/full.xml index 188122e5..607438de 100644 --- a/tests/Resources/Fixtures/config/full.xml +++ b/tests/Resources/Fixtures/config/full.xml @@ -26,6 +26,9 @@ + + +
bar
diff --git a/tests/Resources/Fixtures/config/full.yml b/tests/Resources/Fixtures/config/full.yml index 9b8e266b..03c97d9a 100644 --- a/tests/Resources/Fixtures/config/full.yml +++ b/tests/Resources/Fixtures/config/full.yml @@ -25,6 +25,9 @@ httplug: - base_uri: uri: http://localhost + - + content_type: + skip_detection: true - header_set: headers: diff --git a/tests/Unit/DependencyInjection/ConfigurationTest.php b/tests/Unit/DependencyInjection/ConfigurationTest.php index a6bff258..49dd4003 100644 --- a/tests/Unit/DependencyInjection/ConfigurationTest.php +++ b/tests/Unit/DependencyInjection/ConfigurationTest.php @@ -151,6 +151,12 @@ public function testSupportsAllConfigFormats() 'replace' => false, ], ], + [ + 'content_type' => [ + 'enabled' => true, + 'skip_detection' => true, + ], + ], [ 'header_set' => [ 'enabled' => true, diff --git a/tests/Unit/DependencyInjection/HttplugExtensionTest.php b/tests/Unit/DependencyInjection/HttplugExtensionTest.php index 4c9b7302..0750f5ca 100644 --- a/tests/Unit/DependencyInjection/HttplugExtensionTest.php +++ b/tests/Unit/DependencyInjection/HttplugExtensionTest.php @@ -254,6 +254,32 @@ public function testCachePluginConfigCacheKeyGeneratorReference() $this->assertSame('header_cache_key_generator', (string) $config['cache_key_generator']); } + public function testContentTypePluginAllowedOptions() + { + $this->load([ + 'clients' => [ + 'acme' => [ + 'plugins' => [ + [ + 'content_type' => [ + 'skip_detection' => true, + 'size_limit' => 200000, + ], + ], + ], + ], + ], + ]); + + $cachePlugin = $this->container->findDefinition('httplug.client.acme.plugin.content_type'); + + $config = $cachePlugin->getArgument(0); + $this->assertEquals([ + 'skip_detection' => true, + 'size_limit' => 200000, + ], $config); + } + public function testUsingServiceKeyForClients() { $this->load([