Ejemplo n.º 1
0
 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);
 }