コード例 #1
0
 /**
  * Test if the adminEmail settings get exploded and only 2 e-mails get sent
  *
  * @test
  * @dataProvider messageTypeDataProvider
  * @return void
  */
 public function sendMultipleAdminNewRegistrationMessageReturnsTrueIfSendSuccessful($messageType)
 {
     $event = new \DERHANSEN\SfEventMgt\Domain\Model\Event();
     $registration = new \DERHANSEN\SfEventMgt\Domain\Model\Registration();
     $settings = ['notification' => ['senderEmail' => '*****@*****.**', 'adminEmail' => 'valid1@email.tld,valid2@email.tld ,invalid-email,,']];
     $emailService = $this->getMock('DERHANSEN\\SfEventMgt\\Service\\EmailService', ['sendEmailMessage'], [], '', false);
     $emailService->expects($this->exactly(3))->method('sendEmailMessage')->will($this->returnValue(true));
     $this->inject($this->subject, 'emailService', $emailService);
     $attachmentService = $this->getMock('DERHANSEN\\SfEventMgt\\Service\\Notification\\AttachmentService', ['getAttachments'], [], '', false);
     $attachmentService->expects($this->once())->method('getAttachments');
     $this->inject($this->subject, 'attachmentService', $attachmentService);
     $emailView = $this->getMock('TYPO3\\CMS\\Fluid\\View\\StandaloneView', [], [], '', false);
     $objectManager = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManager', [], [], '', false);
     $objectManager->expects($this->once())->method('get')->will($this->returnValue($emailView));
     $this->inject($this->subject, 'objectManager', $objectManager);
     $hashService = $this->getMock('TYPO3\\CMS\\Extbase\\Security\\Cryptography\\HashService');
     $hashService->expects($this->once())->method('generateHmac')->will($this->returnValue('HMAC'));
     $hashService->expects($this->once())->method('appendHmac')->will($this->returnValue('HMAC'));
     $this->inject($this->subject, 'hashService', $hashService);
     $fluidStandaloneService = $this->getMock('DERHANSEN\\SfEventMgt\\Service\\FluidStandaloneService', [], [], '', false);
     $fluidStandaloneService->expects($this->any())->method('getTemplateFolders')->will($this->returnValue([]));
     $this->inject($this->subject, 'fluidStandaloneService', $fluidStandaloneService);
     $result = $this->subject->sendAdminMessage($event, $registration, $settings, $messageType);
     $this->assertTrue($result);
 }
コード例 #2
0
 /**
  * Confirms the registration if possible and sends e-mails to admin and user
  *
  * @param int $reguid UID of registration
  * @param string $hmac HMAC for parameters
  *
  * @return void
  */
 public function confirmRegistrationAction($reguid, $hmac)
 {
     /* @var $registration Registration */
     $registration = NULL;
     $failed = FALSE;
     $messageKey = 'event.message.confirmation_successful';
     $titleKey = 'confirmRegistration.title.successful';
     if (!$this->hashService->validateHmac('reg-' . $reguid, $hmac)) {
         $failed = TRUE;
         $messageKey = 'event.message.confirmation_failed_wrong_hmac';
         $titleKey = 'confirmRegistration.title.failed';
     } else {
         $registration = $this->registrationRepository->findByUid($reguid);
     }
     if (!$failed && is_null($registration)) {
         $failed = TRUE;
         $messageKey = 'event.message.confirmation_failed_registration_not_found';
         $titleKey = 'confirmRegistration.title.failed';
     }
     if (!$failed && $registration->getConfirmationUntil() < new \DateTime()) {
         $failed = TRUE;
         $messageKey = 'event.message.confirmation_failed_confirmation_until_expired';
         $titleKey = 'confirmRegistration.title.failed';
     }
     if (!$failed && $registration->getConfirmed() === TRUE) {
         $failed = TRUE;
         $messageKey = 'event.message.confirmation_failed_already_confirmed';
         $titleKey = 'confirmRegistration.title.failed';
     }
     if ($failed === FALSE) {
         $registration->setConfirmed(TRUE);
         $this->registrationRepository->update($registration);
         // Send notifications to user and admin
         $this->notificationService->sendUserMessage($registration->getEvent(), $registration, $this->settings, MessageType::REGISTRATION_CONFIRMED);
         $this->notificationService->sendAdminMessage($registration->getEvent(), $registration, $this->settings, MessageType::REGISTRATION_CONFIRMED);
         // Confirm registrations depending on main registration if necessary
         if ($registration->getAmountOfRegistrations() > 1) {
             $this->registrationService->confirmDependingRegistrations($registration);
         }
     }
     $this->view->assign('messageKey', $messageKey);
     $this->view->assign('titleKey', $titleKey);
 }
コード例 #3
0
 /**
  * Cancels the registration if possible and sends e-mails to admin and user
  *
  * @param int $reguid UID of registration
  * @param string $hmac HMAC for parameters
  *
  * @return void
  */
 public function cancelRegistrationAction($reguid, $hmac)
 {
     /* @var $registration Registration */
     list($failed, $registration, $messageKey, $titleKey) = $this->registrationService->checkCancelRegistration($reguid, $hmac);
     if ($failed === false) {
         // Send notifications (must run before cancelling the registration)
         $this->notificationService->sendUserMessage($registration->getEvent(), $registration, $this->settings, MessageType::REGISTRATION_CANCELLED);
         $this->notificationService->sendAdminMessage($registration->getEvent(), $registration, $this->settings, MessageType::REGISTRATION_CANCELLED);
         // First cancel depending registrations
         if ($registration->getAmountOfRegistrations() > 1) {
             $this->registrationService->cancelDependingRegistrations($registration);
         }
         // Finally cancel registration
         $this->registrationRepository->remove($registration);
         // Clear cache for configured pages
         $this->utilityService->clearCacheForConfiguredUids($this->settings);
     }
     $this->view->assign('messageKey', $messageKey);
     $this->view->assign('titleKey', $titleKey);
 }
コード例 #4
0
 /**
  * Test if the adminEmail settings get exploded and only 2 e-mails get sent
  *
  * @test
  * @dataProvider messageTypeDataProvider
  * @return void
  */
 public function sendMultipleAdminNewRegistrationMessageReturnsTrueIfSendSuccessful($messageType)
 {
     $event = new \DERHANSEN\SfEventMgt\Domain\Model\Event();
     $registration = new \DERHANSEN\SfEventMgt\Domain\Model\Registration();
     $settings = array('notification' => array('senderEmail' => '*****@*****.**', 'adminEmail' => 'valid1@email.tld,valid2@email.tld ,invalid-email,,'));
     $emailService = $this->getMock('DERHANSEN\\SfEventMgt\\Service\\EmailService', array('sendEmailMessage'), array(), '', FALSE);
     $emailService->expects($this->exactly(3))->method('sendEmailMessage')->will($this->returnValue(TRUE));
     $this->inject($this->subject, 'emailService', $emailService);
     // Inject configuration and configurationManager
     $configuration = array('plugin.' => array('tx_sfeventmgt.' => array('view.' => array('templateRootPath' => 'EXT:sf_event_mgt/Resources/Private/Templates/', 'layoutRootPath' => 'EXT:sf_event_mgt/Resources/Private/Layouts/'))));
     $configurationManager = $this->getMock('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager', array('getConfiguration'), array(), '', FALSE);
     $configurationManager->expects($this->once())->method('getConfiguration')->will($this->returnValue($configuration));
     $this->inject($this->subject, 'configurationManager', $configurationManager);
     $emailView = $this->getMock('TYPO3\\CMS\\Fluid\\View\\StandaloneView', array(), array(), '', FALSE);
     $objectManager = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManager', array(), array(), '', FALSE);
     $objectManager->expects($this->once())->method('get')->will($this->returnValue($emailView));
     $this->inject($this->subject, 'objectManager', $objectManager);
     $hashService = $this->getMock('TYPO3\\CMS\\Extbase\\Security\\Cryptography\\HashService');
     $hashService->expects($this->once())->method('generateHmac')->will($this->returnValue('HMAC'));
     $hashService->expects($this->once())->method('appendHmac')->will($this->returnValue('HMAC'));
     $this->inject($this->subject, 'hashService', $hashService);
     $result = $this->subject->sendAdminMessage($event, $registration, $settings, $messageType);
     $this->assertTrue($result);
 }