public function testRegisterCallbackInvokedWithAllRegisteredEvents()
 {
     $container = new EventContainer(Uuid::uuid1()->toString());
     $container->addEvent(MetaData::emptyInstance(), new Event());
     $this->assertFalse(current($container->getEventList())->getMetaData()->has("key"));
     $container->addEventRegistrationCallback(new TestEventRegistrationCallback());
     $this->assertEquals("value", current($container->getEventList())->getMetadata()->get("key"));
 }
 /**
  * @return EventContainer
  */
 private function getEventContainer()
 {
     if (null === $this->eventContainer) {
         if (null === $this->getIdentifier()) {
             throw new AggregateRootIdNotInitialized("Aggregate Id unknown in [" . get_class($this) . "] Make sure the Aggregate Id is initialized before registering events.");
         }
         $this->eventContainer = new EventContainer($this->getIdentifier());
         $this->eventContainer->initializeSequenceNumber($this->lastEventScn);
     }
     return $this->eventContainer;
 }