/**
  * @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 checkConfirmRegistration succeeds.
  * Also checks, if messages are sent and if registration gets confirmed.
  *
  * @test
  * @return void
  */
 public function confirmRegistrationActionShowsMessageIfCheckCancelRegistrationSucceeds()
 {
     $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);
     $mockRegistration = $this->getMock('DERHANSEN\\SfEventMgt\\Domain\\Model\\Registration', array(), array(), '', FALSE);
     $mockRegistration->expects($this->once())->method('setConfirmed')->with(TRUE);
     $mockRegistration->expects($this->once())->method('getAmountOfRegistrations')->will($this->returnValue(2));
     $returnedArray = array(FALSE, $mockRegistration, 'event.message.confirmation_successful', 'confirmRegistration.title.successful');
     $mockRegistrationService = $this->getMock('DERHANSEN\\SfEventMgt\\Service\\RegistrationService', array('checkConfirmRegistration', 'confirmDependingRegistrations'), array(), '', FALSE);
     $mockRegistrationService->expects($this->once())->method('checkConfirmRegistration')->will($this->returnValue($returnedArray));
     $mockRegistrationService->expects($this->once())->method('confirmDependingRegistrations')->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('update'), array(), '', FALSE);
     $mockRegistrationRepository->expects($this->once())->method('update');
     $this->inject($this->subject, 'registrationRepository', $mockRegistrationRepository);
     $this->subject->confirmRegistrationAction(1, 'VALID-HMAC');
 }