Problem/Motivation
This only barely counts as bug.
Working on #2415441: Automate finding @covers errors, I encountered ConfigurablePluginCollectionTest which has this annotation:
@coversDefaultClass \Drupal\Component\Plugin\ConfigurablePluginInterface
Generally, you can't test an interface.
Further research led me to discover that ConfigurablePluginCollectionTest really tests DefaultLazyPluginCollection. There is also an existing DefaultLazyPluginCollectionTest, which duplicates effort quite a bit.
ConfigurablePluginCollectionTest and DefaultLazyPluginCollectionTest have nearly identical code in their tests, because they're both extending the same subclass (LazyPluginCollectionTestBase) that provides the same fixture to both.
The fixture is a DefaultLazyPluginCollection with a bunch of mocked ConfigurablePluginInterface objects.
Therefore ConfigurablePluginCollectionTest is actually exercising DefaultLazyPluginCollection, which already has a test which is why we should merge them.
Proposed resolution
- Merge the tests from
ConfigurablePluginCollectionTestintoDefaultLazyPluginCollectionTest. - Improve annotation while we're there.
Remaining tasks
User interface changes
API changes
Beta phase evaluation
| Unfrozen changes | Unfrozen because it only improves automated tests. |
|---|
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | 2423241_1.patch | 7.17 KB | mile23 |
Comments
Comment #1
mile23Not a lot of analysis here, just doing a straight-up merge of the two test classes. There's likely some overlap, but I'm not familiar enough with the plugin system to know if I'd be obliterating any subtleties.
Comment #2
daffie commentedI am not happy with the merge. The problem for me is the class DefaultLazyPluginCollection uses the ConfigurablePluginInterface, but does not implement it.
The ConfigurablePluginCollectionTest with the class TestConfigurablePlugin is in my eyes not very useful. You are only testing test code.
The best solution is to delete the ConfigurablePluginCollectionTest and add new tests where the ConfigurablePluginInterface is implemented.
Comment #3
mile23You can't really test an interface which is what
ConfigurablePluginCollectionTesttries to tell us it's doing.ConfigurablePluginCollectionTestandDefaultLazyPluginCollectionTesthave nearly identical code in their tests, because they're both extending the same subclass (LazyPluginCollectionTestBase) that provides the same fixture to both.The fixture is a
DefaultLazyPluginCollectionwith a bunch of mockedConfigurablePluginInterfaceobjects.Therefore
ConfigurablePluginCollectionTestis actually exercisingDefaultLazyPluginCollection, which already has a test which is why we should merge them. :-)Comment #4
daffie commentedIt all looks good to me.
The ConfigurablePluginInterface tests are moved to DefaultLazyPluginCollectionTest.
Personally the ConfigurablePluginInterface tests could have been deleted completely and not have been moved to an other location, but I can live with this solution too.
It is all about tests and documentation, so it is allowed for beta-changes.
For me it is RTBC.
Comment #5
alexpottCommitted b40b527 and pushed to 8.0.x. Thanks!
Thanks for adding the beta evaluation to the issue summary.