Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upTest closure in DB DataCollector #85
Conversation
|
I'm not sure about this. Here the conversation from gitter. @waltertamboer maybe we need your input here.
|
|
So I'm trying to understand the problem. We have this type of code where the callback is not covered in the unit tests, am I right? <?php
class DataCollector implements SubscriberInterface
{
public function getSubscribedEvents()
{
return [
'...' => function ($options) {
// This is not covered in the unit test.
},
];
}
}We could simply change it to: <?php
class DataCollector implements SubscriberInterface
{
public function getSubscribedEvents()
{
return [
'...' => [$this, 'onAction'],
];
}
public function onAction($options)
{
// This can now be covered.
// It's common sense to never call an on* method.
}
} |
|
Correct @waltertamboer |
|
So can we just make it a public method? That would solve the problem. |
|
Seems like a good approach, indeed |
|
I changed my mind. |
As in #83, too much is happening inside DataCollectors without being tested nor having their inputs validated.
This is an attempt to fix that.