public function testAppendingEventEnvelopeToOpenedEventStream()
 {
     $this->setUpContractResolver();
     $contract = $this->contractResolver->resolveFromClassName(Account::class);
     $existingEventEnvelope = $this->createEventEnvelope(123, new AccountWasOpened('fixture-account-000', 25), 0);
     $persistence = $this->getMockBuilder(Persistence::class)->getMock();
     $persistence->expects($this->once())->method('fetch')->with($this->equalTo($contract), $this->equalTo(123))->will($this->returnValue([$existingEventEnvelope]));
     $eventStream = EventStream::open($persistence, $contract, 123);
     $appendedEventEnvelope = $this->createEventEnvelope(124, new AccountBalanceIncreased('fixture-account-000', 10), 1);
     $eventStream->append($appendedEventEnvelope);
     $this->assertEquals($eventStream->all(), [$existingEventEnvelope, $appendedEventEnvelope]);
 }
Пример #2
0
 public function open(Contract $aggregateRootType, $aggregateRootId)
 {
     return EventStream::open($this->persistence, $aggregateRootType, $aggregateRootId, $this->eventEnvelopeDecorator);
 }