/** * @test */ public function validateAddsErrorForMissingReservation() { $participant = new Person(); $participant->setType(Person::PERSON_TYPE_PARTICIPANT); $expectedResult = new Result(); $expectedError = new Error('Missing reservation.', 1465389725); $expectedResult->addError($expectedError); $this->assertEquals($expectedResult, $this->subject->validate($participant)); }
/** * 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]); }