Пример #1
0
 public function tearDown()
 {
     $this->testHelper->tearDown();
     $this->testHelper = null;
     $this->envelope = null;
     $this->event = null;
 }
 /**
  * @test
  * @expectedException \SimpleES\EventSourcing\Exception\IdNotMappedToAggregate
  */
 public function itCannotReconstituteAnAggregateWhenMapNotFound()
 {
     $factory = new MappingAggregateFactory([]);
     $id = BasketId::fromString('some-id');
     $aggregateHistory = $this->testHelper->getAggregateHistory($id);
     $factory->reconstituteFromHistory($aggregateHistory);
 }
 /**
  * @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);
 }
 /**
  * @test
  */
 public function itEnrichesMetadataWithARondomString()
 {
     $id = BasketId::fromString('some-id');
     $envelope = $this->testHelper->getEventStreamEnvelopeOne($id);
     $enricher = new EnrichesMetadataWithARandomString();
     $enrichedEnvelope = $enricher->enrich($envelope);
     $metadata = $enrichedEnvelope->metadata();
     $this->assertArrayHasKey('random_string', $metadata);
     $this->assertInternalType('string', $metadata['random_string']);
 }
 /**
  * @test
  */
 public function itGetsEventsOfASingleAggregate()
 {
     $id = BasketId::fromString('id-1');
     $eventStream = $this->eventStore->read($id);
     $envelopes = iterator_to_array($eventStream);
     $this->assertInstanceOf('SimpleES\\EventSourcing\\Event\\EventStream', $eventStream);
     $this->assertCount(3, $eventStream);
     $envelopeOne = $this->testHelper->getEventStreamEnvelopeOne($id);
     $envelopeTwo = $this->testHelper->getEventStreamEnvelopeTwo($id);
     $envelopeThree = $this->testHelper->getEventStreamEnvelopeThree($id);
     $this->assertSame($envelopeOne, $envelopes[0]);
     $this->assertSame($envelopeTwo, $envelopes[1]);
     $this->assertSame($envelopeThree, $envelopes[2]);
 }
 /**
  * @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);
 }
Пример #7
0
 /**
  * @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());
 }
Пример #8
0
 public function tearDown()
 {
     $this->testHelper->tearDown();
     $this->testHelper = null;
     $this->identityMap = null;
 }
Пример #9
0
 public function tearDown()
 {
     $this->testHelper->tearDown();
     $this->testHelper = null;
     $this->aggregateHistory = null;
 }
Пример #10
0
 public function tearDown()
 {
     $this->testHelper->tearDown();
     $this->testHelper = null;
     $this->domainEvents = null;
 }
Пример #11
0
 /**
  * @test
  * @expectedException \SimpleES\EventSourcing\Exception\EventStreamIsCorrupt
  */
 public function itContainsOnlyEnvelopesWithTheSameAggregateIdAsItself()
 {
     $id = BasketId::fromString('some-id');
     $otherId = BasketId::fromString('other-id');
     new EventStream($id, [$this->testHelper->getEventStreamEnvelopeOne($otherId)]);
 }