/**
  * @test
  */
 public function removeParticipantUpdatesTotalPrice()
 {
     $this->subject = $this->getAccessibleMock(Reservation::class, ['getLesson']);
     $singlePrice = 123.45;
     $totalPrice = $singlePrice;
     $firstParticipant = new Person();
     $secondParticipant = new Person();
     $objectStorageContainingTwoParticipants = new ObjectStorage();
     $objectStorageContainingTwoParticipants->attach($firstParticipant);
     $objectStorageContainingTwoParticipants->attach($secondParticipant);
     $lesson = $this->getMock(Schedule::class, ['getPrice']);
     $lesson->expects($this->any())->method('getPrice')->will($this->returnValue($singlePrice));
     $this->subject->expects($this->any())->method('getLesson')->will($this->returnValue($lesson));
     $this->subject->setParticipants($objectStorageContainingTwoParticipants);
     $this->subject->removeParticipant($secondParticipant);
     $this->assertSame($totalPrice, $this->subject->getTotalPrice());
 }
 /**
  * action removeParticipant
  *
  * @param Reservation $reservation
  * @param Person $participant
  * @param string $reason Reason for cancellation of reservation for this participant. Allowed:  'byOrganizer', 'withCosts', 'withoutCost'
  * @return void
  */
 public function removeParticipantAction(Reservation $reservation, Person $participant, $reason)
 {
     $reservation->removeParticipant($participant);
     $reservation->getLesson()->removeParticipant($participant);
     $this->personRepository->remove($participant);
     $this->addFlashMessage($this->translate('message.reservation.removeParticipant.success'));
     if ($this->settings['bookings']['removeParticipant'][$reason]['confirm']['sendNotification']) {
         /**@var Notification $notification * */
         $notification = $this->objectManager->get(Notification::class);
         $bodytext = $this->notificationService->render($this->settings['bookings']['removeParticipant'][$reason]['confirm']['templateFileName'], 'html', 'Bookings/Email/RemoveParticipant', ['reservation' => $reservation, 'participant' => $participant, 'reason' => $reason, 'baseUrl' => $this->getBaseUrlForFrontend()]);
         $notification->setRecipient($reservation->getContact()->getEmail());
         $notification->setBodytext($bodytext);
         $notification->setSubject($this->settings['bookings']['removeParticipant'][$reason]['confirm']['subject']);
         $notification->setSender($this->settings['bookings']['removeParticipant'][$reason]['confirm']['fromEmail']);
         $notification->setReservation($reservation);
         $notificationSuccess = $this->notificationService->send($notification);
         if ($notificationSuccess) {
             $mailMessageKey = 'message.bookings.cancel.sendNotification.success';
             $mailMessageSeverity = AbstractMessage::OK;
             $notification->setSentAt(new \DateTime());
         } else {
             $mailMessageKey = 'message.bookings.cancel.sendNotification.error';
             $mailMessageSeverity = AbstractMessage::WARNING;
         }
         $this->notificationRepository->add($notification);
         $this->persistenceManager->persistAll();
         $reservation->addNotification($notification);
         $this->addFlashMessage($this->translate($mailMessageKey), null, $mailMessageSeverity);
     }
     $this->redirect('edit', null, null, ['reservation' => $reservation]);
 }
 /**
  * action removeParticipant
  *
  * @param Reservation $reservation
  * @param Person $participant
  * @return void
  */
 public function removeParticipantAction(Reservation $reservation, Person $participant)
 {
     $reservation->removeParticipant($participant);
     $reservation->getLesson()->removeParticipant($participant);
     $this->personRepository->remove($participant);
     $this->reservationRepository->update($reservation);
     $this->addFlashMessage($this->translate('message.reservation.removeParticipant.success'));
     $this->redirect('edit', null, null, ['reservation' => $reservation]);
 }