Skip to content

Commit f034b16

Browse files
ostroluckyfbourigault
authored andcommitted
Don't remove abstract plugins (#247)
These abstract definitions are needed for client plugin definitions, even if plugins weren't configured at root level. Removal of unused abstract definitions is job of DI container.
1 parent 4c4e25d commit f034b16

File tree

5 files changed

+34
-2
lines changed

5 files changed

+34
-2
lines changed

DependencyInjection/HttplugExtension.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,6 @@ private function configurePlugins(ContainerBuilder $container, array $config)
127127
if ($this->isConfigEnabled($container, $pluginConfig)) {
128128
$def = $container->getDefinition($pluginId);
129129
$this->configurePluginByName($name, $def, $pluginConfig, $container, $pluginId);
130-
} else {
131-
$container->removeDefinition($pluginId);
132130
}
133131
}
134132
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
httplug:
2+
plugins:
3+
cache: ~
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
httplug:
2+
clients:
3+
test:
4+
plugins:
5+
- cache: ~

Tests/Unit/DependencyInjection/ConfigurationTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,4 +355,24 @@ public function testProfilingToolbarCollision()
355355
$file = __DIR__.'/../../Resources/Fixtures/config/bc/profiling_toolbar.yml';
356356
$this->assertProcessedConfigurationEquals([], [$file]);
357357
}
358+
359+
/**
360+
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
361+
* @expectedExceptionMessage The child node "cache_pool" at path "httplug.clients.test.plugins.0.cache" must be configured.
362+
*/
363+
public function testClientCacheConfigMustHavePool()
364+
{
365+
$file = __DIR__.'/../../Resources/Fixtures/config/client_cache_config_with_no_pool.yml';
366+
$this->assertProcessedConfigurationEquals([], [$file]);
367+
}
368+
369+
/**
370+
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
371+
* @expectedExceptionMessage The child node "cache_pool" at path "httplug.plugins.cache" must be configured.
372+
*/
373+
public function testCacheConfigMustHavePool()
374+
{
375+
$file = __DIR__.'/../../Resources/Fixtures/config/cache_config_with_no_pool.yml';
376+
$this->assertProcessedConfigurationEquals([], [$file]);
377+
}
358378
}

Tests/Unit/DependencyInjection/HttplugExtensionTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ public function testClientPlugins()
110110
],
111111
],
112112
],
113+
[
114+
'cache' => [
115+
'cache_pool' => 'my_cache_pool',
116+
],
117+
],
113118
],
114119
],
115120
],
@@ -124,6 +129,7 @@ public function testClientPlugins()
124129
'httplug.client.acme.plugin.header_set',
125130
'httplug.client.acme.plugin.header_remove',
126131
'httplug.client.acme.authentication.my_basic',
132+
'httplug.client.acme.plugin.cache',
127133
];
128134
$pluginReferences = array_map(function ($id) {
129135
return new Reference($id);

0 commit comments

Comments
 (0)