/**
  * Anhand einer Liste werden Users zu den Tagen hinzugefügt fügt es mehere User dem
  */
 public function testBulksUserToDaysFormular()
 {
     $day = $this->createOneDay();
     $day2 = $this->createOneDay("2014-10-23");
     $dayDouppleUser = $this->createOneDay("2014-10-24");
     $user = $this->createUser('testuser');
     $user2 = $this->createUser('testuser2');
     $dayDouppleUser->addUser($user);
     $this->saveInDb([$day, $day2, $dayDouppleUser, $user, $user2]);
     $formular = ['dayid_' . $day->getId() => [$user->getId(), $user2->getId() + 333], 'dayid_' . $day2->getId() => [$user->getId(), $user2->getId(), 'wrong_id'], 'dayid_' . $dayDouppleUser->getId() => [$user->getId(), $user2->getId()], 'dayid_' . ($day2->getId() + 333) => [2, 3], 'error' => [1, 2]];
     $manager = $this->getDoctrine()->getManager();
     $handler = new DayAndUserRelationship($manager);
     $bulksUsersToDays = new BulksUsersToDays($manager, $handler);
     $bulksUsersToDays->processForm($formular);
     $day2toSave = $bulksUsersToDays->getEntitys();
     $this->assertCount(3, $day2toSave, 'Item `dayid_+333` und `error` sind nicht vorhanden ');
     $this->assertEquals((string) $day, (string) $day2toSave[0]);
     $this->assertEquals((string) $day2, (string) $day2toSave[1]);
     $this->assertCount(1, $day2toSave[0]->getTaUsers(), 'User `+333` darf nicht vorhanden sein, weil es nicht exitiert');
     $this->assertCount(2, $day2toSave[1]->getTaUsers(), 'Die wrong_id ist falsch und darf nicht vorhanden sein');
     $this->assertCount(2, $day2toSave[2]->getTaUsers());
     $this->saveInDb($day2toSave);
 }
 /**
  * Der Admin fügt user zu einer DB hinzu
  *
  * @Route("/add-users")
  * @Method({"POST"})
  * @Security("has_role('ROLE_ADMIN')")
  *
  * @param Request $request
  */
 public function adminAddUserToDay(Request $request)
 {
     $formular = $request->get('adduserdate');
     if (empty($formular)) {
         $this->addFlash('danger', 'page.calendar.admin_empty_form');
         return $this->redirectToRoute('trolley_agenda_calendar_index');
     }
     $manager = $this->getDoctrine()->getManager();
     $dayAndUserRelationship = new DayAndUserRelationship($manager);
     $bulksUsersToDays = new BulksUsersToDays($manager, $dayAndUserRelationship);
     $bulksUsersToDays->processForm($formular);
     $manager->flush();
     $this->addFlash('success', 'page.calendar.admin_add_user');
     return $this->redirectToRoute('trolley_agenda_calendar_index');
 }