/** * @test * @return void */ public function confirmRegistrationActionConfirmsDependentRegistrations() { $view = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\View\\ViewInterface'); $view->expects($this->at(0))->method('assign')->with('messageKey', 'event.message.confirmation_successful'); $view->expects($this->at(1))->method('assign')->with('titleKey', 'confirmRegistration.title.successful'); $this->inject($this->subject, 'view', $view); $hashService = $this->getMock('TYPO3\\CMS\\Extbase\\Security\\Cryptography\\HashService', array('validateHmac'), array(), '', FALSE); $hashService->expects($this->once())->method('validateHmac')->will($this->returnValue(TRUE)); $this->inject($this->subject, 'hashService', $hashService); $expiredConfirmationDateTime = new \DateTime('tomorrow'); $registration = $this->getMock('DERHANSEN\\SfEventMgt\\Domain\\Model\\Registration', array(), array(), '', FALSE); $registration->expects($this->once())->method('getConfirmationUntil')->will($this->returnValue($expiredConfirmationDateTime)); $registration->expects($this->once())->method('getConfirmed')->will($this->returnValue(FALSE)); $registration->expects($this->once())->method('getAmountOfRegistrations')->will($this->returnValue(2)); $registrationRepository = $this->getMock('DERHANSEN\\SfEventMgt\\Domain\\Repository\\RegistrationRepository', array('findByUid', 'update'), array(), '', FALSE); $registrationRepository->expects($this->once())->method('findByUid')->will($this->returnValue($registration)); $registrationRepository->expects($this->once())->method('update'); $this->inject($this->subject, 'registrationRepository', $registrationRepository); $notificationService = $this->getMock('DERHANSEN\\SfEventMgt\\Service\\NotificationService', array(), array(), '', FALSE); $notificationService->expects($this->once())->method('sendUserMessage'); $notificationService->expects($this->once())->method('sendAdminMessage'); $this->inject($this->subject, 'notificationService', $notificationService); $registrationService = $this->getMock('DERHANSEN\\SfEventMgt\\Service\\RegistrationService', array('confirmDependingRegistrations'), array(), '', FALSE); $registrationService->expects($this->once())->method('confirmDependingRegistrations')->with($registration); $this->inject($this->subject, 'registrationService', $registrationService); $this->subject->confirmRegistrationAction(1, 'VALID-HMAC'); }
/** * Test if expected message is shown if checkCancelRegistration succeeds. * Also checks, if messages are sent and if registration gets removed. * * @test * @return void */ public function cancelRegistrationActionShowsMessageIfCheckCancelRegistrationSucceeds() { $view = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\View\\ViewInterface'); $view->expects($this->at(0))->method('assign')->with('messageKey', 'event.message.cancel_successful'); $view->expects($this->at(1))->method('assign')->with('titleKey', 'cancelRegistration.title.successful'); $this->inject($this->subject, 'view', $view); $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)); $mockRegistration->expects($this->any())->method('getAmountOfRegistrations')->will($this->returnValue(2)); $returnedArray = array(FALSE, $mockRegistration, 'event.message.cancel_successful', 'cancelRegistration.title.successful'); $mockRegistrationService = $this->getMock('DERHANSEN\\SfEventMgt\\Service\\RegistrationService', array('checkCancelRegistration', 'cancelDependingRegistrations'), array(), '', FALSE); $mockRegistrationService->expects($this->once())->method('checkCancelRegistration')->will($this->returnValue($returnedArray)); $mockRegistrationService->expects($this->once())->method('cancelDependingRegistrations')->with($mockRegistration); $this->inject($this->subject, 'registrationService', $mockRegistrationService); $mockNotificationService = $this->getMock('DERHANSEN\\SfEventMgt\\Service\\NotificationService', array(), array(), '', FALSE); $mockNotificationService->expects($this->once())->method('sendUserMessage'); $mockNotificationService->expects($this->once())->method('sendAdminMessage'); $this->inject($this->subject, 'notificationService', $mockNotificationService); $mockRegistrationRepository = $this->getMock('DERHANSEN\\SfEventMgt\\Domain\\Repository\\RegistrationRepository', array('remove'), array(), '', FALSE); $mockRegistrationRepository->expects($this->once())->method('remove'); $this->inject($this->subject, 'registrationRepository', $mockRegistrationRepository); $mockUtilityService = $this->getMock('DERHANSEN\\SfEventMgt\\Service\\UtilityService', array('clearCacheForConfiguredUids'), array(), '', FALSE); $mockUtilityService->expects($this->once())->method('clearCacheForConfiguredUids'); $this->inject($this->subject, 'utilityService', $mockUtilityService); $this->subject->cancelRegistrationAction(1, 'VALID-HMAC'); }
/** * @test * @return void */ public function searchActionDoesNotOverridesDemandIfOverwriteDemandDisabled() { $searchDemand = $this->getMock('DERHANSEN\\SfEventMgt\\Domain\\Model\\Dto\\SearchDemand', [], [], '', false); $searchDemand->expects($this->once())->method('setFields'); $demand = $this->getMock('DERHANSEN\\SfEventMgt\\Domain\\Model\\Dto\\EventDemand', ['setSearchDemand'], [], '', false); $demand->expects($this->once())->method('setSearchDemand')->with($searchDemand); $overrideDemand = ['category' => 10]; $this->subject->expects($this->never())->method('overwriteEventDemandObject'); $settings = ['disableOverrideDemand' => 1]; $this->inject($this->subject, 'settings', $settings); $this->subject->expects($this->once())->method('createEventDemandObjectFromSettings')->with($settings)->will($this->returnValue($demand)); $eventRepository = $this->getMock('DERHANSEN\\SfEventMgt\\Domain\\Repository\\EventRepository', ['findDemanded'], [], '', false); $eventRepository->expects($this->once())->method('findDemanded')->will($this->returnValue($allEvents)); $this->inject($this->subject, 'eventRepository', $eventRepository); $categoryRepository = $this->getMock('DERHANSEN\\SfEventMgt\\Domain\\Repository\\CategoryRepository', ['findDemanded'], [], '', false); $categoryRepository->expects($this->once())->method('findDemanded')->will($this->returnValue($allCategories)); $this->inject($this->subject, 'categoryRepository', $categoryRepository); $locationRepository = $this->getMock('DERHANSEN\\SfEventMgt\\Domain\\Repository\\LocationRepository', ['findDemanded'], [], '', false); $locationRepository->expects($this->once())->method('findDemanded')->will($this->returnValue($allLocations)); $this->inject($this->subject, 'locationRepository', $locationRepository); $view = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\View\\ViewInterface'); $this->inject($this->subject, 'view', $view); $this->subject->searchAction($searchDemand, $overrideDemand); }