/** * @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); }
/** * 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; }