protected function setUp() { $this->initEventStoreAdapter(); $this->getEventStoreAdapter()->createSchema(array('User')); $eventStoreConfig = new Configuration(); $eventStoreConfig->setAdapter($this->getEventStoreAdapter()); $eventStore = new EventStore($eventStoreConfig); $this->repository = $eventStore->getRepository('Malocher\\EventStoreTest\\Coverage\\Mock\\User'); }
public function testGetCustomRepository() { $config = new Configuration(); $config->setAdapter($this->getEventStoreAdapter()); $config->addRepositoryMapping('Malocher\\EventStoreTest\\Coverage\\Mock\\User', 'Malocher\\EventStoreTest\\Coverage\\Mock\\MockedRepository'); $this->eventStore = new EventStore($config); $repo = $this->eventStore->getRepository('Malocher\\EventStoreTest\\Coverage\\Mock\\User'); $this->assertInstanceOf('Malocher\\EventStoreTest\\Coverage\\Mock\\MockedRepository', $repo); }
/** * Construct * * @param Configuration $config */ public function __construct(Configuration $config) { $this->adapter = $config->getAdapter(); $this->lookupSnapshots = $config->isSnapshotLookup(); $this->autoGenerateSnapshots = $config->isAutoGenerateSnapshots(); $this->snapshotInterval = $config->getSnapshotInterval(); $this->repositoryMap = $config->getRepositoryMap(); $this->eventDispatcher = $config->getEventDispatcher(); if ($this->autoGenerateSnapshots) { $this->lookupSnapshots = true; } }
/** * Create new EventStore instance * * @param ServiceLocatorInterface $serviceLocator * * @return EventStore */ public function createService(ServiceLocatorInterface $serviceLocator) { $globalConfig = array(); $localConfig = array(); $appConfig = $serviceLocator->get('configuration'); if (isset($appConfig['malocher.eventstore'])) { $globalConfig = $appConfig['malocher.eventstore']; } if (file_exists('config/eventstore.config.php')) { $localConfig = (include 'config/eventstore.config.php'); } $esConfig = new Configuration(array_merge($globalConfig, $localConfig)); $esConfig->setEventDispatcher($serviceLocator->get('malocher.eventstore.eventdispatcher')); return new EventStore($esConfig); }
public function testSetEventDispatcher() { $config = new Configuration(array('event_dispatcher' => array('Malocher\\EventStoreTest\\Coverage\\Mock\\MockedEventDispatcher' => array()))); $eventDispatcher = new EventDispatcher(); $config->setEventDispatcher($eventDispatcher); //Ignore array config and return manually set EventDispatcher $this->assertSame($eventDispatcher, $config->getEventDispatcher()); }