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

Support prooph/event-store v6 #7

Merged
merged 2 commits into from
Oct 13, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
],
"require": {
"php": ">=5.5",
"prooph/event-store" : "^5.1",
"prooph/event-store" : "dev-develop",
"prooph/service-bus" : "^4.0"
},
"require-dev": {
Expand Down
8 changes: 5 additions & 3 deletions src/TransactionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
*/
namespace Prooph\EventStoreBusBridge;

use Iterator;
use ArrayIterator;
use Prooph\Common\Event\ActionEvent;
use Prooph\Common\Event\ActionEventEmitter;
use Prooph\Common\Event\ActionEventListenerAggregate;
Expand Down Expand Up @@ -74,10 +76,10 @@ public function attach(ActionEventEmitter $emitter)
* adds the causation_id (command UUID) and causation_name (name of the command which has caused the events)
* as metadata to each event.
*
* @param Message[] $recordedEvents
* @param Iterator $recordedEvents
* @return Message[]
Copy link
Member

Choose a reason for hiding this comment

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

update return phpdoc

*/
private function handleRecordedEvents(array $recordedEvents)
private function handleRecordedEvents(Iterator $recordedEvents)
{
if (is_null($this->currentCommand) || ! $this->currentCommand instanceof Message) {
return $recordedEvents;
Expand All @@ -95,7 +97,7 @@ private function handleRecordedEvents(array $recordedEvents)
$enrichedRecordedEvents[] = $recordedEvent;
}

return $enrichedRecordedEvents;
return new ArrayIterator($enrichedRecordedEvents);
}

/**
Expand Down
8 changes: 4 additions & 4 deletions tests/TransactionManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public function it_adds_causation_id_and_causation_name_on_event_store_create_st
$recordedEventCopy1->withAddedMetadata('causation_name', 'causation-message-name')->willReturn($recordedEventCopy2->reveal());
$recordedEvent->withAddedMetadata('causation_id', $causationId->toString())->willReturn($recordedEventCopy1->reveal());

$stream = new Stream(new StreamName('event_stream'), [$recordedEvent->reveal()]);
$stream = new Stream(new StreamName('event_stream'), new \ArrayIterator([$recordedEvent->reveal()]));

$createStreamActionEvent = $this->prophesize(ActionEvent::class);

Expand Down Expand Up @@ -254,7 +254,7 @@ public function it_adds_causation_id_and_causation_name_on_event_store_append_to

$appendToStreamActionEvent = $this->prophesize(ActionEvent::class);

$appendToStreamActionEvent->getParam('streamEvents')->willReturn([$recordedEvent->reveal()]);
$appendToStreamActionEvent->getParam('streamEvents')->willReturn(new \ArrayIterator([$recordedEvent->reveal()]));

$enrichedEvents = null;
$appendToStreamActionEvent->setParam('streamEvents', Argument::any())
Expand All @@ -265,7 +265,7 @@ public function it_adds_causation_id_and_causation_name_on_event_store_append_to
$transactionManager->onEventStoreAppendToStream($appendToStreamActionEvent->reveal());

$this->assertNotNull($enrichedEvents);
$this->assertTrue(is_array($enrichedEvents));
$this->assertInstanceOf(\ArrayIterator::class, $enrichedEvents);
$this->assertEquals(1, count($enrichedEvents));
$this->assertSame($recordedEventCopy2->reveal(), $enrichedEvents[0]);
}
Expand Down Expand Up @@ -310,7 +310,7 @@ public function it_returns_early_if_command_was_null_when_handling_events()

$recordedEvent->withAddedMetadata('causation_id', Argument::any())->shouldNotBeCalled();

$stream = new Stream(new StreamName('event_stream'), [$recordedEvent->reveal()]);
$stream = new Stream(new StreamName('event_stream'), new \ArrayIterator([$recordedEvent->reveal()]));

$createStreamActionEvent = new DefaultActionEvent('test');
$createStreamActionEvent->setParam('stream', $stream);
Expand Down