Skip to content

Commit

Permalink
Merge pull request #7 from codeliner/feature/pes_6
Browse files Browse the repository at this point in the history
Support prooph/event-store v6
  • Loading branch information
prolic committed Oct 13, 2015
2 parents f0c8dc7 + e3fe790 commit 1ad2a05
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
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
10 changes: 6 additions & 4 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
* @return Message[]
* @param Iterator $recordedEvents
* @return Iterator
*/
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

0 comments on commit 1ad2a05

Please sign in to comment.