/** * Test if expected array is returned if registration already confirmed * * @test * @return void */ public function checkConfirmRegistrationIfRegistrationConfirmedTest() { $reguid = 1; $hmac = 'valid-hmac'; $mockRegistration = $this->getMock('DERHANSEN\\SfEventMgt\\Domain\\Model\\Registration', array(), array(), '', FALSE); $mockRegistration->expects($this->any())->method('getConfirmationUntil')->will($this->returnValue(new \DateTime('tomorrow'))); $mockRegistration->expects($this->any())->method('getConfirmed')->will($this->returnValue(TRUE)); $mockRegistrationRepository = $this->getMock('DERHANSEN\\SfEventMgt\\Domain\\Repository\\RegistrationRepository', array('findByUid'), array(), '', FALSE); $mockRegistrationRepository->expects($this->once())->method('findByUid')->with(1)->will($this->returnValue($mockRegistration)); $this->inject($this->subject, 'registrationRepository', $mockRegistrationRepository); $mockHashService = $this->getMock('TYPO3\\CMS\\Extbase\\Security\\Cryptography\\HashService', array('validateHmac'), array(), '', FALSE); $mockHashService->expects($this->once())->method('validateHmac')->will($this->returnValue(TRUE)); $this->inject($this->subject, 'hashService', $mockHashService); $result = $this->subject->checkConfirmRegistration($reguid, $hmac); $expected = array(TRUE, $mockRegistration, 'event.message.confirmation_failed_already_confirmed', 'confirmRegistration.title.failed'); $this->assertEquals($expected, $result); }
/** * 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 */ list($failed, $registration, $messageKey, $titleKey) = $this->registrationService->checkConfirmRegistration($reguid, $hmac); if ($failed === false) { $registration->setConfirmed(true); $this->registrationRepository->update($registration); $messageType = MessageType::REGISTRATION_CONFIRMED; if ($registration->getWaitlist()) { $messageType = MessageType::REGISTRATION_WAITLIST_CONFIRMED; } // Send notifications to user and admin $this->notificationService->sendUserMessage($registration->getEvent(), $registration, $this->settings, $messageType); $this->notificationService->sendAdminMessage($registration->getEvent(), $registration, $this->settings, $messageType); // Confirm registrations depending on main registration if necessary if ($registration->getAmountOfRegistrations() > 1) { $this->registrationService->confirmDependingRegistrations($registration); } } // Redirect to payment provider if payment/redirect is enabled $paymentPid = (int) $this->settings['paymentPid']; if (!$failed && $paymentPid > 0 && $this->registrationService->redirectPaymentEnabled($registration)) { $this->uriBuilder->reset()->setTargetPageUid($paymentPid)->setUseCacheHash(false); $uri = $this->uriBuilder->uriFor('redirect', ['registration' => $registration, 'hmac' => $this->hashService->generateHmac('redirectAction-' . $registration->getUid())], 'Payment', 'sfeventmgt', 'Pipayment'); $this->redirectToUri($uri); } $this->view->assign('messageKey', $messageKey); $this->view->assign('titleKey', $titleKey); }
/** * 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 */ list($failed, $registration, $messageKey, $titleKey) = $this->registrationService->checkConfirmRegistration($reguid, $hmac); 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); }