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 testDispatchPreCommitEvent() { $this->eventStore->beginTransaction(); $user = new User('1'); $user->changeName('Malocher'); $user->changeEmail('*****@*****.**'); $persistedEventList = array(); $this->eventStore->events()->addListener(PostPersistEvent::NAME, function (PostPersistEvent $e) use(&$persistedEventList) { foreach ($e->getPersistedEvents() as $persistedEvent) { $persistedEventList[] = get_class($persistedEvent); } }); $this->eventStore->events()->addListener(PreCommitEvent::NAME, function (PreCommitEvent $e) use($user) { $e->getEventStore()->save($user); }); $this->eventStore->commit(); $check = array('Malocher\\EventStoreTest\\Coverage\\Mock\\Event\\UserNameChangedEvent', 'Malocher\\EventStoreTest\\Coverage\\Mock\\Event\\UserEmailChangedEvent'); $this->assertEquals($check, $persistedEventList); }
/** * {@inheritDoc} */ public function save(EventSourcedObject $eventSourcedObject) { $this->eventStore->save($eventSourcedObject); }