/** * @test */ public function itSimplyProxiesGettingEventsToTheNextEventStore() { $id = BasketId::fromString('some-id'); $eventStream = $this->testHelper->getEventStream($id); $this->nextEventStore->expects($this->once())->method('read')->with($this->equalTo($id))->will($this->returnValue($eventStream)); $returnedEnvelopeStream = $this->eventStore->read($id); $this->assertSame($eventStream, $returnedEnvelopeStream); }
public function setUp() { $this->testHelper = new TestHelper($this); $idOne = BasketId::fromString('id-1'); $eventStreamOne = $this->testHelper->getEventStream($idOne); $idTwo = BasketId::fromString('id-2'); $eventStreamTwo = $this->testHelper->getEventStream($idTwo); $this->eventStore = new InMemoryEventStore(); $this->eventStore->commit($eventStreamOne); $this->eventStore->commit($eventStreamTwo); }
/** * @test */ public function itReconstitutesAnAggregateFromHistoryRetrievedFromTheEventStore() { $id = BasketId::fromString('some-basket'); $eventStream = $this->testHelper->getEventStream($id); $aggregateHistory = $this->testHelper->getAggregateHistory($id); $aggregate = Basket::pickUp($id); $this->eventStore->expects($this->once())->method('read')->with($this->equalTo($id))->will($this->returnValue($eventStream)); $this->eventWrapper->expects($this->once())->method('unwrap')->with($this->equalTo($eventStream))->will($this->returnValue($aggregateHistory)); $this->aggregateFactory->expects($this->once())->method('reconstituteFromHistory')->with($this->equalTo($aggregateHistory))->will($this->returnValue($aggregate)); $foundAggregate = $this->repository->get($id); $this->assertSame($aggregate, $foundAggregate); }
/** * @test */ public function itMaintainsConsecutivePlayheadAfterUnwrapping() { $id = BasketId::fromString('some-id'); $domainEvents = $this->testHelper->getDomainEvents($id); $eventStream = $this->testHelper->getEventStream($id); $this->eventWrapper->unwrap($eventStream); $newEnvelopeStream = $this->eventWrapper->wrap($id, $domainEvents); /** @var EnvelopsEvent[] $envelopes */ $envelopes = iterator_to_array($newEnvelopeStream); $this->assertSame(3, $envelopes[0]->aggregateVersion()); $this->assertSame(4, $envelopes[1]->aggregateVersion()); $this->assertSame(5, $envelopes[2]->aggregateVersion()); }