Esempio n. 1
0
 /**
  * @test
  * @group library
  */
 public function mailTextShouldContainConfiguredUri()
 {
     $userOptinUriPath = '/bar/';
     $formerOptinUri = $this->changeUserOptinUri($userOptinUriPath);
     $user = new \Cms\Data\User();
     $user->setId('USER-test5421shd-USER');
     $user->setFirstname('John');
     $user->setLastname('Doe');
     $user->setEmail('*****@*****.**');
     $optin = new \Orm\Entity\OptIn();
     $optin->setCode('testRS01');
     $optin->setUserId($user->getId());
     $optin->setUser($user);
     $mail = $this->service->getOptinMail($optin);
     $this->changeUserOptinUri($formerOptinUri);
     $mailContent = $mail->getBodyText('true');
     $mailContent = str_replace("=\r\n", "", $mailContent);
     $mailContent = str_replace("=\n", "", $mailContent);
     $optinUrl = Registry::getBaseUrl() . $userOptinUriPath . '?t=';
     $this->assertTrue(strchr($mailContent, $optinUrl) !== false);
     $this->assertTrue(strchr($mailContent, $optin->getCode()) !== false);
 }
Esempio n. 2
0
 /**
  * Convert assoc array to user object
  * @param $assocUserArray
  * @return \Cms\Data\User
  */
 protected function getUserFromArray($assocUserArray)
 {
     // validate fields
     try {
         $this->validateRequiredFields($assocUserArray);
     } catch (\Exception $e) {
         Registry::getLogger()->logException(__METHOD__, __LINE__, $e, Log::ERR);
         return null;
     }
     $user = new \Cms\Data\User();
     $user->setId($assocUserArray['id']);
     // user is readonly and not deletable
     $user->setReadonly(true);
     $user->setDeletable(false);
     // required fields
     $user->setFirstname($assocUserArray['firstname']);
     $user->setLastname($assocUserArray['lastname']);
     $user->setEmail($assocUserArray['email']);
     $user->setPassword($assocUserArray['password']);
     // optional
     if (isset($assocUserArray['gender'])) {
         $user->setGender($assocUserArray['gender']);
     }
     if (isset($assocUserArray['language'])) {
         $user->setLanguage($assocUserArray['language']);
     }
     if (isset($assocUserArray['passwordResetUrl'])) {
         $sourceInfo = $user->getSourceInfo();
         $sourceInfo['passwordResetUrl'] = $assocUserArray['passwordResetUrl'];
         $user->setSourceInfo($sourceInfo);
     }
     if (isset($assocUserArray['dashboardUrl'])) {
         $sourceInfo = $user->getSourceInfo();
         $sourceInfo['dashboardUrl'] = $assocUserArray['dashboardUrl'];
         $user->setSourceInfo($sourceInfo);
     }
     if (isset($assocUserArray['upgradeUrl'])) {
         $sourceInfo = $user->getSourceInfo();
         $sourceInfo['upgradeUrl'] = $assocUserArray['upgradeUrl'];
         $user->setSourceInfo($sourceInfo);
     }
     return $user;
 }
 /**
  * @return \Cms\Business\User
  */
 protected function getUserBusinessMock()
 {
     $stub = $this->getMockBuilder('\\Cms\\Business\\User')->disableOriginalConstructor()->getMock();
     $user1 = new \Cms\Data\User();
     $user1->setId('user-1');
     $user2 = new \Cms\Data\User();
     $user2->setId('user-2');
     $stub->expects($this->any())->method('getAll')->will($this->returnValue(array($user1, $user2)));
     return $stub;
 }
Esempio n. 4
0
 /**
  * Liefert ein CMS Datenobjekt zurueck mit den Werten des ORM Objektes
  *
  * @return  \Cms\Data\User
  */
 public function toCmsData()
 {
     $dataObject = new \Cms\Data\User();
     $dataObject->setId($this->getId())->setDeletable($this->isDeletable())->setEmail($this->getEmail())->setFirstname($this->getFirstname())->setGender($this->getGender())->setLanguage($this->getLanguage())->setGroups($this->getGroups())->setLastname($this->getLastname())->setPassword($this->getPassword())->setSuperuser($this->isSuperuser())->setOwner(false)->setLastUpdate($this->getLastupdate());
     return $dataObject;
 }