/**
  * Checks, if a saveRegistration action creates multiple registrations
  * if getAmountOfRegistrations > 1
  *
  * @test
  * @return void
  */
 public function saveRegistrationCreatesMultipleRegistrationIfAmountOfRegistrationsGreatherThanOne()
 {
     $registration = $this->getMock('DERHANSEN\\SfEventMgt\\Domain\\Model\\Registration', array(), array(), '', FALSE);
     $registration->expects($this->any())->method('getAmountOfRegistrations')->will($this->returnValue(2));
     $registrations = $this->getMock('TYPO3\\CMS\\Extbase\\Persistence\\ObjectStorage', array(), array(), '', FALSE);
     $registrations->expects($this->any())->method('count')->will($this->returnValue(9));
     $event = $this->getMock('DERHANSEN\\SfEventMgt\\Domain\\Model\\Event', array(), array(), '', FALSE);
     $startdate = new \DateTime();
     $startdate->add(\DateInterval::createFromDateString('tomorrow'));
     $event->expects($this->once())->method('getEnableRegistration')->will($this->returnValue(TRUE));
     $event->expects($this->once())->method('getStartdate')->will($this->returnValue($startdate));
     $event->expects($this->any())->method('getRegistration')->will($this->returnValue($registrations));
     $event->expects($this->any())->method('getMaxParticipants')->will($this->returnValue(10));
     $event->expects($this->any())->method('getFreePlaces')->will($this->returnValue(10));
     $event->expects($this->any())->method('getMaxRegistrationsPerUser')->will($this->returnValue(2));
     $registrationRepository = $this->getMock('DERHANSEN\\SfEventMgt\\Domain\\Repository\\RegistrationRepository', array('add'), array(), '', FALSE);
     $registrationRepository->expects($this->once())->method('add');
     $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);
     $persistenceManager = $this->getMock('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager', array('persistAll'), array(), '', FALSE);
     $persistenceManager->expects($this->once())->method('persistAll');
     $objectManager = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManager', array('get'), array(), '', FALSE);
     $objectManager->expects($this->any())->method('get')->will($this->returnValue($persistenceManager));
     $this->inject($this->subject, 'objectManager', $objectManager);
     $settingsService = $this->getMock('DERHANSEN\\SfEventMgt\\Service\\SettingsService', array('getClearCacheUids'), array(), '', FALSE);
     $settingsService->expects($this->once())->method('getClearCacheUids')->will($this->returnValue(array('0' => '1')));
     $this->inject($this->subject, 'settingsService', $settingsService);
     $cacheService = $this->getMock('TYPO3\\CMS\\Extbase\\Service\\CacheService', array('clearPageCache'), array(), '', FALSE);
     $cacheService->expects($this->once())->method('clearPageCache');
     $this->inject($this->subject, 'cacheService', $cacheService);
     $registrationService = $this->getMock('DERHANSEN\\SfEventMgt\\Service\\RegistrationService', array('createDependingRegistrations'), array(), '', FALSE);
     $registrationService->expects($this->once())->method('createDependingRegistrations')->with($registration);
     $this->inject($this->subject, 'registrationService', $registrationService);
     $this->subject->expects($this->once())->method('redirect')->with('saveRegistrationResult', NULL, NULL, array('result' => RegistrationResult::REGISTRATION_SUCCESSFUL));
     $this->subject->saveRegistrationAction($registration, $event);
 }
 /**
  * @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);
 }