/**
  * @test
  * @expectedException \InvalidArgumentException
  */
 public function it_does_not_allow_to_add_stream_events_with_wrong_repository_aggregate_type()
 {
     $this->eventStore->beginTransaction();
     $user = User::create("John Doe", "*****@*****.**");
     $aggregateType = AggregateType::fromAggregateRoot($user);
     $aggregateId = Uuid::uuid4()->toString();
     $streamEvents = [UserCreated::with(['user_id' => $aggregateId], 1)];
     $this->strategy->addEventsForNewAggregateRoot($aggregateType, $aggregateId, $streamEvents, $user);
     $this->eventStore->commit();
     $this->eventStore->beginTransaction();
     $streamEvents = [UsernameChanged::with(['name' => 'John Doe'], 2)];
     $this->strategy->appendEvents(AggregateType::fromString("Product"), $aggregateId, $streamEvents, $user);
 }
Пример #2
0
 /**
  * @return Stream
  */
 private function getTestStream()
 {
     $streamEvent = UserCreated::with(['name' => 'Alex', 'email' => '*****@*****.**'], 1);
     return new Stream(new StreamName('user'), [$streamEvent]);
 }
 /**
  * @return Stream
  */
 private function getTestStream()
 {
     $streamEvent = UserCreated::with(['name' => 'Max Mustermann', 'email' => '*****@*****.**'], 1);
     $streamEvent = $streamEvent->withAddedMetadata('tag', 'person');
     return new Stream(new StreamName('Prooph\\Model\\User'), [$streamEvent]);
 }
 /**
  * @return Stream
  */
 private function getTestStream()
 {
     $streamEvent = UserCreated::with(array('name' => 'Max Mustermann', 'email' => '*****@*****.**'), 1);
     DomainEventMetadataWriter::setMetadataKey($streamEvent, 'tag', 'person');
     return new Stream(new StreamName('Prooph\\Model\\User'), array($streamEvent));
 }
Пример #5
0
 /**
  * @test
  */
 public function it_reads_stream_events_for_aggregate()
 {
     $this->eventStore->beginTransaction();
     $user = User::create("John Doe", "*****@*****.**");
     $aggregateType = AggregateType::fromString('Object');
     $aggregateId1 = Uuid::uuid4()->toString();
     $streamEvents1 = [UserCreated::with(['user_id' => $aggregateId1], 1)];
     $this->strategy->addEventsForNewAggregateRoot($aggregateType, $aggregateId1, $streamEvents1, $user);
     $product = new Product();
     $aggregateId2 = Uuid::uuid4()->toString();
     $streamEvents2 = [TestDomainEvent::with(['product_id' => $aggregateId2], 1)];
     $this->strategy->addEventsForNewAggregateRoot($aggregateType, $aggregateId2, $streamEvents2, $product);
     $this->eventStore->commit();
     $streamEvents = $this->strategy->read($aggregateType, $aggregateId2);
     $this->assertEquals(1, count($streamEvents));
     $this->assertInstanceOf(DomainEvent::class, $streamEvents[0]);
     $this->assertEquals($aggregateId2, $streamEvents[0]->payload()['product_id']);
     $arType = $this->strategy->getAggregateRootType($aggregateType, $streamEvents);
     $this->assertEquals('Prooph\\EventStoreTest\\Mock\\Product', $arType->toString());
 }