Skip to content

Commit 35d2818

Browse files
authored
Merge pull request #334 from pixelart/fix/content-type-plugin
Remove enabled key from content type plugin options
2 parents be11c56 + c1ba3b0 commit 35d2818

File tree

7 files changed

+49
-0
lines changed

7 files changed

+49
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
The change log describes what is "Added", "Removed", "Changed" or "Fixed" between each release.
44

5+
### Fixed
6+
7+
- Fix to pass only allowed options to the `ContentTypePlugin`.
8+
59
## 1.15.1 - 2019-04-12
610

711
### Fixed

src/DependencyInjection/HttplugExtension.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,9 @@ private function configurePluginByName($name, Definition $definition, array $con
270270
break;
271271

272272
case 'content_type':
273+
unset($config['enabled']);
273274
$definition->replaceArgument(0, $config);
275+
274276
break;
275277

276278
case 'header_append':

tests/Resources/Fixtures/config/full.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@
3535
'uri' => 'http://localhost',
3636
],
3737
],
38+
[
39+
'content_type' => [
40+
'skip_detection' => true,
41+
],
42+
],
3843
[
3944
'header_set' => [
4045
'headers' => [

tests/Resources/Fixtures/config/full.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
<plugin>
2727
<base-uri uri="http://localhost"/>
2828
</plugin>
29+
<plugin>
30+
<content-type skip-detection="true"/>
31+
</plugin>
2932
<plugin>
3033
<header-set>
3134
<header name="X-FOO">bar</header>

tests/Resources/Fixtures/config/full.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ httplug:
2525
-
2626
base_uri:
2727
uri: http://localhost
28+
-
29+
content_type:
30+
skip_detection: true
2831
-
2932
header_set:
3033
headers:

tests/Unit/DependencyInjection/ConfigurationTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,12 @@ public function testSupportsAllConfigFormats()
151151
'replace' => false,
152152
],
153153
],
154+
[
155+
'content_type' => [
156+
'enabled' => true,
157+
'skip_detection' => true,
158+
],
159+
],
154160
[
155161
'header_set' => [
156162
'enabled' => true,

tests/Unit/DependencyInjection/HttplugExtensionTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,32 @@ public function testCachePluginConfigCacheKeyGeneratorReference()
254254
$this->assertSame('header_cache_key_generator', (string) $config['cache_key_generator']);
255255
}
256256

257+
public function testContentTypePluginAllowedOptions()
258+
{
259+
$this->load([
260+
'clients' => [
261+
'acme' => [
262+
'plugins' => [
263+
[
264+
'content_type' => [
265+
'skip_detection' => true,
266+
'size_limit' => 200000,
267+
],
268+
],
269+
],
270+
],
271+
],
272+
]);
273+
274+
$cachePlugin = $this->container->findDefinition('httplug.client.acme.plugin.content_type');
275+
276+
$config = $cachePlugin->getArgument(0);
277+
$this->assertEquals([
278+
'skip_detection' => true,
279+
'size_limit' => 200000,
280+
], $config);
281+
}
282+
257283
public function testUsingServiceKeyForClients()
258284
{
259285
$this->load([

0 commit comments

Comments
 (0)