/** * Test if expected array is returned if cancellation deadline expired * * @test * @return void */ public function checkCancelRegistrationIfCancellationDeadlineExpiredTest() { $reguid = 1; $hmac = 'valid-hmac'; $mockEvent = $this->getMock('DERHANSEN\\SfEventMgt\\Domain\\Model\\Event', array(), array(), '', FALSE); $mockEvent->expects($this->any())->method('getEnableCancel')->will($this->returnValue(TRUE)); $mockEvent->expects($this->any())->method('getCancelDeadline')->will($this->returnValue(new \DateTime('yesterday'))); $mockRegistration = $this->getMock('DERHANSEN\\SfEventMgt\\Domain\\Model\\Registration', array(), array(), '', FALSE); $mockRegistration->expects($this->any())->method('getEvent')->will($this->returnValue($mockEvent)); $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->checkCancelRegistration($reguid, $hmac); $expected = array(TRUE, $mockRegistration, 'event.message.cancel_failed_deadline_expired', 'cancelRegistration.title.failed'); $this->assertEquals($expected, $result); }
/** * 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); }