Skip to content

Don't remove abstract plugins #247

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions DependencyInjection/HttplugExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,6 @@ private function configurePlugins(ContainerBuilder $container, array $config)
if ($this->isConfigEnabled($container, $pluginConfig)) {
$def = $container->getDefinition($pluginId);
$this->configurePluginByName($name, $def, $pluginConfig, $container, $pluginId);
} else {
$container->removeDefinition($pluginId);
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions Tests/Resources/Fixtures/config/cache_config_with_no_pool.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
httplug:
plugins:
cache: ~
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
httplug:
clients:
test:
plugins:
- cache: ~
20 changes: 20 additions & 0 deletions Tests/Unit/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -355,4 +355,24 @@ public function testProfilingToolbarCollision()
$file = __DIR__.'/../../Resources/Fixtures/config/bc/profiling_toolbar.yml';
$this->assertProcessedConfigurationEquals([], [$file]);
}

/**
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
* @expectedExceptionMessage The child node "cache_pool" at path "httplug.clients.test.plugins.0.cache" must be configured.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use $this->expectException and $this->expectExceptionMessage instead of the annotations. the annotations have been deprecated in favor of the method. they have the upsides of being able to use the ::class constant and (not relevant in this case here) of only accepting the exception at the place you actually expect it, not before that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no instance in this code base where expectExceptionMessage is used. I've followed style of existing code.

Furthermore, expectException is PHPUnit 6+ only.

If you decided to change the code style, please do it yourself with refactoring commit which replaces it in all places at once.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, my bad. i am working in too many repositories that are at different states of upgrading those things... indeed, its better to be consistent with this. i created #248

*/
public function testClientCacheConfigMustHavePool()
{
$file = __DIR__.'/../../Resources/Fixtures/config/client_cache_config_with_no_pool.yml';
$this->assertProcessedConfigurationEquals([], [$file]);
}

/**
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
* @expectedExceptionMessage The child node "cache_pool" at path "httplug.plugins.cache" must be configured.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

*/
public function testCacheConfigMustHavePool()
{
$file = __DIR__.'/../../Resources/Fixtures/config/cache_config_with_no_pool.yml';
$this->assertProcessedConfigurationEquals([], [$file]);
}
}
6 changes: 6 additions & 0 deletions Tests/Unit/DependencyInjection/HttplugExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ public function testClientPlugins()
],
],
],
[
'cache' => [
'cache_pool' => 'my_cache_pool',
],
],
],
],
],
Expand All @@ -124,6 +129,7 @@ public function testClientPlugins()
'httplug.client.acme.plugin.header_set',
'httplug.client.acme.plugin.header_remove',
'httplug.client.acme.authentication.my_basic',
'httplug.client.acme.plugin.cache',
];
$pluginReferences = array_map(function ($id) {
return new Reference($id);
Expand Down