public function testSetSemester() { $substitute = new Substitute(); $semester = new Semester(); $substitute->setSemester($semester); $this->assertEquals($semester, $substitute->getSemester()); }
/** * 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); }
public function load(ObjectManager $manager) { $sub1 = new Substitute(); $sub1->setFirstName('Marius'); $sub1->setLastName('Svendsen'); $sub1->setEmail('*****@*****.**'); $sub1->setPhone('95128535'); $sub1->setFieldOfStudy($this->getReference('fos-1')); $sub1->setYearOfStudy(1); $sub1->setSemester($this->getReference('semester-1')); $sub1->setMonday("Bra"); $sub1->setTuesday("Ikke"); $sub1->setWednesday("Ikke"); $sub1->setThursday("Ok"); $sub1->setFriday("Bra"); $manager->persist($sub1); $sub2 = new Substitute(); $sub2->setFirstName('Amalie'); $sub2->setLastName('Nilsen'); $sub2->setEmail('*****@*****.**'); $sub2->setPhone('45872561'); $sub2->setYearOfStudy(2); $sub2->setFieldOfStudy($this->getReference('fos-1')); $sub2->setSemester($this->getReference('semester-1')); $sub2->setMonday("Ok"); $sub2->setTuesday("Ikke"); $sub2->setWednesday("Ok"); $sub2->setThursday("Bra"); $sub2->setFriday("Bra"); $manager->persist($sub2); $sub3 = new Substitute(); $sub3->setFirstName('Sebastian'); $sub3->setLastName('Kleiveland'); $sub3->setEmail('*****@*****.**'); $sub3->setPhone('97586258'); $sub3->setYearOfStudy(3); $sub3->setFieldOfStudy($this->getReference('fos-1')); $sub3->setSemester($this->getReference('semester-1')); $sub3->setMonday("Bra"); $sub3->setTuesday("Bra"); $sub3->setWednesday("Ok"); $sub3->setThursday("Bra"); $sub3->setFriday("Ikke"); $manager->persist($sub3); $sub4 = new Substitute(); $sub4->setFirstName('Elisabeth'); $sub4->setLastName('Kleven'); $sub4->setEmail('*****@*****.**'); $sub4->setPhone('95147835'); $sub4->setYearOfStudy(1); $sub4->setFieldOfStudy($this->getReference('fos-1')); $sub4->setSemester($this->getReference('semester-1')); $sub4->setMonday("Ikke"); $sub4->setTuesday("Bra"); $sub4->setWednesday("Ok"); $sub4->setThursday("Ikke"); $sub4->setFriday("Ok"); $manager->persist($sub4); $sub5 = new Substitute(); $sub5->setFirstName('Sonja'); $sub5->setLastName('Vågen'); $sub5->setEmail('*****@*****.**'); $sub5->setPhone('95142536'); $sub5->setYearOfStudy(4); $sub5->setFieldOfStudy($this->getReference('fos-1')); $sub5->setSemester($this->getReference('semester-1')); $sub5->setMonday("Bra"); $sub5->setTuesday("Bra"); $sub5->setWednesday("Ikke"); $sub5->setThursday("Bra"); $sub5->setFriday("Ok"); $manager->persist($sub5); $manager->flush(); }