Skip to content
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

Expose Notifier Interface to announce fixture status #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

nootanghimire
Copy link
Contributor

Exposes an interface called NotifierInterface, and call NotifierInterface::notify to notify individual fixture status.

Use case

I use this library to run my fixtures. However, I've to pass all the fixtures at once. I need to be able to get information about each of the fixtures succeeding or failing.

PS: If you have any suggestions in regards to the Name, then please comment. I'll rename this.

PPS: Upon more thinking, I wonder if implementing a PSR Logger (and start writing logs) is better than this. 🤔 Open to discussions!

Expose NotifierInterface so that any code using the libarary
can implement it to do whatever they want with the information
we provide
Copy link
Contributor

@wyrfel wyrfel left a comment

Choose a reason for hiding this comment

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

Offering integration with PSR loggers is a nice thought. Would open up more easy integrations. You wouldn't even have to supply it here but could just replace $this->getNotifier()->notify() with $this->getLogger()->info(). Then again, you would only be using a single method in that interface and require people that want to implement their own to implement all the other methods. To avoid that you could keep the Notifier as an intermediary and provide a PsrLogNotifier to easily interface with Loggers instead. The latter is more flexible, the former is a bit leaner. Not really sure which way i'd go.


public function testImplementsNotifierInstance()
{
$this->assertInstanceOf('TheIconic\Fixtures\Notifier\NotifierInterface', $this->notifierInstance);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd do

use TheIconic\Fixtures\Notifier\NotifierInterface;
...
$this->assertInstanceOf(NotifierInterface::class, $this->notifierInstance);

@estringana
Copy link
Contributor

@nootanghimire it would be nice if you could add a test to fixtures manager to verify the notification works. What do you think?

@estringana
Copy link
Contributor

My opinion is to leave the logger implement the NotifierInterface and then log things on the implementation. The way you have done, it gives you more option on the future(if needed). You also remove the dependency of having a logger on this class.

Last point I would say is to not create a NullNotifier notifier if not created. I wouldn't notify anyone if notifier is null.

@estringana
Copy link
Contributor

Nice job done here, none of my comment are a blocker for this PRs, just some points of views

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants