public static function setFromDTO(User &$user, UserDTO $userDTO)
 {
     $user->setExternalId($userDTO->externalId);
     $user->setEmail($userDTO->email);
     $user->setFirstName($userDTO->firstName);
     $user->setLastName($userDTO->lastName);
     if ($userDTO->status !== null) {
         $user->setStatus(UserStatusType::createById($userDTO->status->id));
     }
 }
Exemple #2
0
 public function testSetPasswordRaisesEvent()
 {
     $user = new User();
     $user->setEmail('*****@*****.**');
     $user->setPassword('Password1');
     $this->assertSame(0, count($user->releaseEvents()));
     $user->setPassword('NewPassword123');
     /** @var PasswordChangedEvent $event */
     $event = $user->releaseEvents()[0];
     $this->assertTrue($event instanceof PasswordChangedEvent);
     $this->assertSame($user->getId(), $event->getUserId());
     $this->assertSame($user->getEmail(), $event->getEmail());
     $this->assertSame($user->getFullName(), $event->getFullName());
 }
 /**
  * @param Iterator $iterator
  * @return ImportResult
  */
 public function import(Iterator $iterator)
 {
     $importResult = new ImportResult();
     foreach ($iterator as $key => $row) {
         if ($key < 2 && $row[0] === 'id') {
             continue;
         }
         $externalId = $this->extractNull($row[0]);
         $name = $this->extractNull($row[1]);
         $address = $this->extractNull($row[2]);
         $zip5 = $this->extractNull($row[3]);
         $city = $this->extractNull($row[4]);
         $phone = $this->extractNull($row[5]);
         $fax = $this->extractNull($row[6]);
         $url = $this->extractNull($row[7]);
         $email = $this->extractNull($row[8]);
         $firstName = $this->parseFirstName($name);
         $lastName = $this->parseLastName($name);
         $user = new User();
         $user->setExternalId($externalId);
         $user->setFirstName($firstName);
         $user->setLastName($lastName);
         if (!empty($email)) {
             $user->setEmail($email);
         }
         try {
             $this->throwValidationErrors($user);
             $this->userRepository->create($user);
             $importResult->incrementSuccess();
         } catch (KommerceException $e) {
             $importResult->addFailedRow($row);
             $importResult->addErrorMessage($e->getMessage());
         }
     }
     return $importResult;
 }
Exemple #4
0
 public function getUser($externalId = null)
 {
     $user = new User();
     $user->setExternalId($externalId);
     $user->setEmail('test' . $externalId . '@example.com');
     $user->setPassword('password1');
     $user->setFirstName('John');
     $user->setLastName('Doe');
     return $user;
 }