/**
  * @test
  */
 public function itShouldCreateTheEvent()
 {
     $event = new UserCreatedEvent($this->id, $this->username, $this->language);
     $this->assertEquals($this->id, $event->getUserId());
     $this->assertEquals($this->username, $event->getUsername());
     $this->assertEquals($this->language, $event->getPreferredLanguage());
 }
 /**
  * @param UserCreatedEvent $event
  */
 public function handleUserCreatedEvent(UserCreatedEvent $event)
 {
     $this->logger->info('Message read model received user event');
     $user = $this->finder->find((string) $event->getUserId());
     if ($user) {
         $user->setName($event->getUsername());
         $user->setPreferredLanguage($event->getPreferredLanguage());
     } else {
         $user = $this->appUserFactory->create($event->getUserId(), $event->getUsername(), $event->getPreferredLanguage());
     }
     $this->finder->save($user);
 }
示例#3
0
 /**
  * Apply the user created event
  *
  * @param \MessageApp\Event\UserCreatedEvent $event
  */
 protected function applyUserCreatedEvent(UserCreatedEvent $event)
 {
     $this->id = $event->getUserId();
     $this->name = $event->getUsername();
     $this->preferredLanguage = $event->getPreferredLanguage();
     $this->thirdPartyAccounts = [];
 }