Пример #1
0
 public function testRegisterClick()
 {
     $authCodeForLink = md5($this->authCode . 3001);
     $this->linkRepository->registerClick(30, $authCodeForLink, false);
     $link = $this->linkRepository->findByUid(3001);
     $this->assertEquals(1, $link->getOpenedCount(), 'the link opened count must have been incrementated');
     $this->assertRecipientListCallbackWasCalled('clicked recipient2@example.com');
     $db = $this->getDatabaseConnection();
     $count = $db->exec_SELECTcountRows('*', 'tx_newsletter_domain_model_linkopened', 'link = 3001 AND email = 302');
     $this->assertEquals(1, $count, 'must have exactly 1 linkopened record for this link');
     $email = $this->emailRepository->findByUid(302);
     $this->assertTrue($email->isOpened(), 'email should be marked as open, even if the open spy did not work, because a link was clicked');
     $this->assertRecipientListCallbackWasCalled('opened recipient2@example.com');
 }
 public function testRegisterClick()
 {
     $authCodeForLink = md5($this->authCode . 3001);
     $url = $this->linkRepository->registerClick(30, $authCodeForLink, false);
     $this->assertEquals('http://example.com/index.php?id=1&tx_newsletter_p%5Baction%5D=show&tx_newsletter_p%5Bcontroller%5D=Email&type=1342671779&c=87c4e9b09085befbb7f20faa7482213a', $url, 'the URL returned must have markers substituted');
     $link = $this->linkRepository->findByUid(3001);
     $this->assertEquals(1, $link->getOpenedCount(), 'the link opened count must have been incrementated');
     $this->assertRecipientListCallbackWasCalled('clicked recipient2@example.com');
     $db = $this->getDatabaseConnection();
     $count = $db->exec_SELECTcountRows('*', 'tx_newsletter_domain_model_linkopened', 'link = 3001 AND email = 302');
     $this->assertEquals(1, $count, 'must have exactly 1 linkopened record for this link');
     $email = $this->emailRepository->findByUid(302);
     $this->assertTrue($email->isOpened(), 'email should be marked as open, even if the open spy did not work, because a link was clicked');
     $this->assertRecipientListCallbackWasCalled('opened recipient2@example.com');
 }
Пример #3
0
 /**
  * Register when a link was clicked and redirect to link's URL.
  * For this method we don't use extbase parameters system to have an URL as short as possible
  */
 public function clickedAction()
 {
     $args = $this->request->getArguments();
     // For compatibility with old links
     $oldArgs = ['n', 'l', 'p'];
     foreach ($oldArgs as $arg) {
         if (!isset($args[$arg])) {
             if (isset($_REQUEST[$arg])) {
                 $args[$arg] = $_REQUEST[$arg];
             }
         }
     }
     $url = $this->linkRepository->registerClick(@$args['n'], @$args['l'], @$args['p']);
     // Finally redirect to the destination URL
     if ($url) {
         // This gives a proper 303 redirect.
         $this->redirectToUri($url);
         die;
     } else {
         throw new \TYPO3\CMS\Core\Error\Http\PageNotFoundException('The requested link was not found', 1440490767);
     }
 }