Пример #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);
 }
Пример #2
0
 /**
  * @test
  * @group library
  */
 public function isValidTimeboxShouldReturnTrueWhenUnlimitedLifetimeIsConfigured()
 {
     $formerLifetime = OptinTestHelper::changeConfiguredLifetime(\Orm\Entity\OptIn::MODE_REGISTER, 0);
     $optin = new \Orm\Entity\OptIn();
     $optin->setTimestamp(new \DateTime());
     $optin->setMode(\Orm\Entity\OptIn::MODE_REGISTER);
     $isValidTimeboxMethod = new \ReflectionMethod('Cms\\Service\\Optin', 'isValidTimebox');
     $isValidTimeboxMethod->setAccessible(true);
     $this->assertTrue($isValidTimeboxMethod->invoke($this->service, $optin));
     OptinTestHelper::changeConfiguredLifetime(\Orm\Entity\OptIn::MODE_REGISTER, $formerLifetime);
     $formerLifetime = OptinTestHelper::changeConfiguredLifetime(\Orm\Entity\OptIn::MODE_PASSWORD, 0);
     $optin = new \Orm\Entity\OptIn();
     $optin->setTimestamp(new \DateTime());
     $optin->setMode(\Orm\Entity\OptIn::MODE_PASSWORD);
     $isValidTimeboxMethod = new \ReflectionMethod('Cms\\Service\\Optin', 'isValidTimebox');
     $isValidTimeboxMethod->setAccessible(true);
     $this->assertTrue($isValidTimeboxMethod->invoke($this->service, $optin));
     OptinTestHelper::changeConfiguredLifetime(\Orm\Entity\OptIn::MODE_PASSWORD, $formerLifetime);
 }