public function testSetStatistic() { $application = new Application(); $applicationStatistic = new ApplicationStatistic(); $application->setStatistic($applicationStatistic); $this->assertEquals($applicationStatistic, $application->getStatistic()); }
/** * Creates a substitute assistant with the info from the given application. * If an interview has been conducted, the work day information is taken from InterviewPractical, * if not it is left as null values and can be filled in by manually editing the substitute. * This method is intended to be called by an Ajax request. * * @param Application $application * @return JsonResponse */ public function createAction(Application $application) { // Only admin or team members withing the same department as the applicant can create substitute if ($this->get('security.authorization_checker')->isGranted('ROLE_SUPER_ADMIN') || $application->isSameDepartment($this->getUser())) { $appStat = $application->getStatistic(); $intPrac = $appStat->getInterviewPractical(); $substitute = new Substitute(); $substitute->setFirstName($application->getFirstName()); $substitute->setLastName($application->getLastName()); $substitute->setPhone($application->getPhone()); $substitute->setEmail($application->getEmail()); $substitute->setFieldOfStudy($appStat->getFieldOfStudy()); $substitute->setYearOfStudy($appStat->getYearOfStudy()); $substitute->setSemester($appStat->getSemester()); if ($intPrac) { $substitute->setMonday($intPrac->getMonday()); $substitute->setTuesday($intPrac->getTuesday()); $substitute->setWednesday($intPrac->getWednesday()); $substitute->setThursday($intPrac->getThursday()); $substitute->setFriday($intPrac->getFriday()); } $application->setSubstituteCreated(true); $em = $this->getDoctrine()->getManager(); $em->persist($substitute); $em->persist($application); $em->flush(); // AJAX response $response['success'] = true; } else { // AJAX response $response['success'] = false; $response['cause'] = 'Ikke tilstrekkelige rettigheter.'; } return new JsonResponse($response); }