/**
  * @test
  */
 public function addParticipantUpdatesTotalPrice()
 {
     $this->subject = $this->getAccessibleMock(Reservation::class, ['getLesson']);
     $singlePrice = 123.45;
     $totalPrice = 2 * $singlePrice;
     $firstParticipant = new Person();
     $secondParticipant = new Person();
     $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(new ObjectStorage());
     $this->subject->addParticipant($secondParticipant);
     $this->subject->addParticipant($firstParticipant);
     $this->assertSame($totalPrice, $this->subject->getTotalPrice());
 }
 /**
  * action createParticipant
  *
  * @param Reservation $reservation
  * @param Person $newParticipant
  * @return void
  */
 public function createParticipantAction(Reservation $reservation, Person $newParticipant)
 {
     if (!$reservation->getStatus() == Reservation::STATUS_DRAFT) {
         $reservation->setStatus(Reservation::STATUS_DRAFT);
     }
     $newParticipant->setType(Person::PERSON_TYPE_PARTICIPANT);
     $reservation->getLesson()->addParticipant($newParticipant);
     $reservation->addParticipant($newParticipant);
     $this->reservationRepository->update($reservation);
     $this->persistenceManager->persistAll();
     $this->addFlashMessage($this->translate('message.reservation.createParticipant.success'));
     $this->redirect('edit', null, null, ['reservation' => $reservation]);
 }
 /**
  * @test
  */
 public function editActionAssignsVariablesToView()
 {
     $participant = new Person();
     $reservation = new Reservation();
     $reservation->addParticipant($participant);
     $participant->setReservation($reservation);
     $view = $this->mockView();
     $view->expects($this->once())->method('assign')->with('participant', $participant);
     $this->subject->editAction($participant, $reservation);
 }