/**
  * @test
  * @dataProvider eventStoreProvider
  * @param $eventStoreAdapter
  * @param $snapshotAdapter
  */
 public function isShouldStoreEvents($eventStoreAdapter, $snapshotAdapter)
 {
     $locator = new InMemoryLocator();
     $commandBus = new SimpleCommandBus($locator);
     $eventBus = new SimpleEventBus();
     $eventStore = new EventStore($eventStoreAdapter);
     $snapshotStore = new SnapshotStore($snapshotAdapter);
     $snapshotter = new Snapshotter($snapshotStore, new CountSnapshotStrategy($eventStore, 5));
     $aggregateRepo = new AggregateRepository($eventStore, $eventBus, $snapshotter);
     $locator->addHandler(AssignNameCommand::class, new AssignNameHandler($aggregateRepo));
     $aggregateRoot = AggregateRoot::create(AggregateId::generate(), 'test1');
     $aggregateRepo->save($aggregateRoot);
     $command = new AssignNameCommand($aggregateRoot->getAggregateRootId(), 'test2');
     $commandBus->execute($command);
     $commandBus->execute($command);
     $commandBus->execute($command);
     $commandBus->execute($command);
     $this->assertEquals(6, $eventStore->countEventsFor(new StreamName('event_stream'), $aggregateRoot->getAggregateRootId()));
 }
 public function aggregateRootProvider()
 {
     return [[AggregateRoot::create(AggregateId::generate(), 'test1')]];
 }
Ejemplo n.º 3
0
 public function messageProvider()
 {
     return [[AggregateId::generate(), AggregateRoot::create(AggregateId::generate(), 'v1000'), '1000', new \DateTimeImmutable()], [AggregateId::generate(), AggregateRoot::create(AggregateId::generate(), 'v1'), '1', \DateTimeImmutable::createFromFormat('U.u', sprintf('%.6F', microtime(true)))]];
 }
Ejemplo n.º 4
0
 /**
  * @test
  */
 public function itIndicatedThatASnapshotOfAggregateIsUnknownWhenTheVersionIsIncorrect()
 {
     $id = AggregateId::generate();
     $this->mockRedisHasAndGetData($id, 20);
     $adapter = $this->createAdapter();
     $result = $adapter->has($id, 15);
     $this->assertFalse($result);
 }
Ejemplo n.º 5
0
 public function idDataProvider()
 {
     return ['Simple String' => ['Yolntbyaac'], 'Identitiy' => [AggregateId::generate()], 'UUID String' => [Uuid::uuid4()->toString()]];
 }
Ejemplo n.º 6
0
 /**
  * @test
  */
 public function itShouldCreateAUuidFromNamedConstructor()
 {
     $aggregateId = AggregateId::generate();
     $this->assertInstanceOf(AggregateIdInterface::class, $aggregateId);
 }
Ejemplo n.º 7
0
 public function messageProvider()
 {
     return [[AggregateId::generate(), 1, new SomethingHappened(), new \DateTimeImmutable()], [AggregateId::generate(), 100, new SomethingHappened(), new \DateTimeImmutable()], [AggregateId::generate(), 9999999, new SomethingHappened(), new \DateTimeImmutable()], [AggregateId::generate(), 9999999, new SomethingHappened(), \DateTimeImmutable::createFromFormat('U.u', sprintf('%.6F', microtime(true)))]];
 }