/** * Bei gefunden User wird er zum Tag hin zugefügt * * @param integer $userid * @param Day $day */ protected function addUserToDay($userid, Day $day) { $userRepository = $this->getUserRepository(); $user = $userRepository->find($userid); if ($user) { $this->dayAndUserRelationship->addUserToDay($user, $day); } }
public function it_be_add_tow_user_to_onw_day(EntityManagerInterface $entityManager, DayRepository $dayRepository, UserRepository $userRepository, DayAndUserRelationship $dayAndUserRelationship, Day $day, User $user) { $entityManager->getRepository(Argument::is("TrolleyAgendaBundle:Day"))->willReturn($dayRepository)->shouldBeCalled(); $entityManager->getRepository(Argument::is("TrolleyAgendaBundle:User"))->willReturn($userRepository)->shouldBeCalled(); $dayRepository->find('31')->willReturn($day)->shouldBeCalled(); $userRepository->find('20')->willReturn($user)->shouldBeCalled(); $userRepository->find('errorID')->shouldNotBeCalled(); $dayAndUserRelationship->addUserToDay(Argument::is($user->getWrappedObject()), Argument::is($day->getWrappedObject()))->shouldBeCalled(); $formular = ['dayid_31' => [20, 'errorID']]; $this->processForm($formular); }
/** * Schliest einen Tag um sich dort nicht anmelden zu können * * @Route("/close-day") * @Method({"POST"}) * @Security("has_role('ROLE_ADMIN')") * * @param Request $request */ public function adminCloseDayAction(Request $request) { $params = $request->get('params'); if (empty($params['message'])) { $this->addFlash('danger', 'page.calendar.admin_empty_closed_message'); return $this->redirectToRoute('trolley_agenda_calendar_index'); } if (empty($params['day'])) { $this->addFlash('danger', 'page.calendar.admin_empty_day_id'); return $this->redirectToRoute('trolley_agenda_calendar_index'); } $dayRepo = $this->getDoctrine()->getRepository('TrolleyAgendaBundle:Day'); $day = $dayRepo->find($params['day']); if (empty($day)) { $this->addFlash('danger', 'page.calendar.admin_empty_day_id'); return $this->redirectToRoute('trolley_agenda_calendar_index'); } $manager = $this->getDoctrine()->getManager(); $dayAndUserRelationship = new DayAndUserRelationship($manager); $dayAndUserRelationship->removeAllUserFromDay($day); $day->closeDayWithMessage($params['message']); $manager->flush(); $this->addFlash('success', 'page.calendar.admin_day_closed'); return $this->redirectToRoute('trolley_agenda_calendar_index'); }