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

Fix OnEventStrategy #151

Merged
merged 9 commits into from
Jan 10, 2017
Merged

Fix OnEventStrategy #151

merged 9 commits into from
Jan 10, 2017

Conversation

mablae
Copy link
Member

@mablae mablae commented Jan 7, 2017

Closes #150

Copy link
Member

@prolic prolic left a comment

Choose a reason for hiding this comment

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

Can you also please update the copyright year to 2017 ?

MessageBus::PRIORITY_INVOKE_HANDLER
);


Copy link
Member

Choose a reason for hiding this comment

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

one new line too much

@prolic prolic added the bug label Jan 7, 2017
@prolic prolic self-assigned this Jan 7, 2017
@prolic prolic added this to the 6.0 Release milestone Jan 7, 2017
@coveralls
Copy link

Coverage Status

Coverage remained the same at 99.407% when pulling aa05412 on mablae:fix-invoke-event-bus into bd5dc09 on prooph:develop.

@prolic
Copy link
Member

prolic commented Jan 7, 2017

LICENSE file is missing update

@prolic
Copy link
Member

prolic commented Jan 7, 2017

TestCase?

$handlers = $actionEvent->getParam(EventBus::EVENT_PARAM_EVENT_LISTENERS);

foreach ($handlers as $handler) {
$this->invoke($handler, $message);
Copy link
Member

Choose a reason for hiding this comment

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

can be simply: $handler->onEvent($message); and method public function invoke($handler, $message): void can be removed.

Copy link
Member Author

Choose a reason for hiding this comment

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

okay

Copy link
Member

Choose a reason for hiding this comment

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

can be simply: $handler->onEvent($message);

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@@ -1,4 +1,4 @@
Copyright (c) 2013, Alexander Miertsch contact@prooph.de
Copyright (c) 2017, Alexander Miertsch contact@prooph.de
Copy link
Member

Choose a reason for hiding this comment

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

should be:

Copyright (c) 2013-2017, prooph software GmbH
Copyright (c) 2015-2017, Sascha-Oliver Prolic

@coveralls
Copy link

Coverage Status

Coverage remained the same at 99.407% when pulling a9bd5c1 on mablae:fix-invoke-event-bus into bd5dc09 on prooph:develop.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 99.407% when pulling c26c70d on mablae:fix-invoke-event-bus into bd5dc09 on prooph:develop.

@mablae mablae force-pushed the fix-invoke-event-bus branch from 6844740 to 8cc2ad9 Compare January 8, 2017 18:14
@coveralls
Copy link

Coverage Status

Coverage increased (+0.006%) to 99.413% when pulling 8cc2ad9 on mablae:fix-invoke-event-bus into bd5dc09 on prooph:develop.

use Prooph\ServiceBus\MessageBus;
use Prooph\ServiceBus\Plugin\AbstractPlugin;

class OnEventStrategy extends AbstractPlugin
{
/**
* @param mixed $handler
Copy link
Member

Choose a reason for hiding this comment

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

Unnecessary doc header parameters could be removed.

use Prooph\ServiceBus\MessageBus;
use Prooph\ServiceBus\Plugin\AbstractPlugin;

class OnEventStrategy extends AbstractPlugin
Copy link
Member

Choose a reason for hiding this comment

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

This class could be final, i guess.

Copy link
Member

Choose a reason for hiding this comment

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

yes, final class please

$onEventStrategy->attachToMessageBus($bus->reveal());

$bus->attach(Argument::type('string'), Argument::type('callable'), Argument::type('integer'))->shouldHaveBeenCalled();
$prophet->checkPredictions();
Copy link
Member

Choose a reason for hiding this comment

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

Instead of manuell run checkPredictions(), you could run

$bus->attach(Argument::type('string'), Argument::type('callable'), Argument::type('integer'))
    ->shouldBeCalled()
    ->willReturn(new DefaultListenerHandler(function () {}));

Then checkPredictions() would be executed from PHPUnit.

Copy link
Member Author

Choose a reason for hiding this comment

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

@oqq Thank you, I will try it!

{
$onEventStrategy = new OnEventStrategy();

$prophet = new \Prophecy\Prophet();
Copy link
Member

Choose a reason for hiding this comment

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

This line is unnecessary. See comment below.


$prophet = new \Prophecy\Prophet();

$bus = $prophet->prophesize(EventBus::class);
Copy link
Member

Choose a reason for hiding this comment

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

Could be $this->prophesize(). See comment below.

@mablae mablae changed the title WIP: Fix OnEventStrategy Fix OnEventStrategy Jan 9, 2017
Copy link
Member

@prolic prolic left a comment

Choose a reason for hiding this comment

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

only some last minor things

use Prooph\ServiceBus\MessageBus;
use Prooph\ServiceBus\Plugin\AbstractPlugin;

class OnEventStrategy extends AbstractPlugin
Copy link
Member

Choose a reason for hiding this comment

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

yes, final class please

@@ -22,4 +27,22 @@ public function invoke($handler, $message): void
{
$handler->onEvent($message);
Copy link
Member

Choose a reason for hiding this comment

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

remove this method

Copy link
Member Author

Choose a reason for hiding this comment

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

Then I need to adjust the testcases, too and mock the handler->onEvent() call, too?

$handlers = $actionEvent->getParam(EventBus::EVENT_PARAM_EVENT_LISTENERS);

foreach ($handlers as $handler) {
$this->invoke($handler, $message);
Copy link
Member

Choose a reason for hiding this comment

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

can be simply: $handler->onEvent($message);

new DefaultListenerHandler(
function () {

}
Copy link
Member

Choose a reason for hiding this comment

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

function () {}: void

Copy link
Member

Choose a reason for hiding this comment

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

{} on the same line would be against PSR-2 (not sure whether this repository is following PSR-2).

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, php-cs-fixer would complain then, been there already :)

@coveralls
Copy link

Coverage Status

Coverage increased (+0.009%) to 99.416% when pulling 34e7fb6 on mablae:fix-invoke-event-bus into bd5dc09 on prooph:develop.

@prolic prolic merged commit 8dab4aa into prooph:develop Jan 10, 2017
@mablae mablae deleted the fix-invoke-event-bus branch January 10, 2017 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants