public function testRepeatedDrivingAssertionCRUD() { $driverCategory = $this->createDriverCategory('Zivildienst'); $address = Address::registerAddress('Burstrasse 22c', '6333', 'Baar', 'Schweiz'); $this->init->addressRepo->store($address); $driver = Driver::registerDriver('m', 'Max', 'Mühlemann', '041 222 32 32', $address, 'F3234141', $driverCategory, true, '', '*****@*****.**', new \DateTime(), new \DateTime(), 5, 'alles nur ein Test'); $this->init->driverRepo->store($driver); $shiftTypes[] = $this->createShiftType('Shift 1'); $shiftTypes[] = $this->createShiftType('Shift 2'); //weekly $repeatedDrivingAssertionWeekly = new RepeatedWeeklyDrivingAssertion(); $repeatedDrivingAssertionWeekly->setWeekday(1); $repeatedDrivingAssertionWeekly->setShiftTypes($shiftTypes); $this->init->repeatedDrivingAssertionRepo->store($repeatedDrivingAssertionWeekly); $repeatedDrivingAssertionPlan = RepeatedDrivingAssertionPlan::registerRepeatedAssertionPlan('test', new \DateTime(), 'weekly', true); $repeatedDrivingAssertionPlan->assignDriver($driver); $repeatedDrivingAssertionPlan->assignRepeatedDrivingAssertion($repeatedDrivingAssertionWeekly); $this->init->repeatedDrivingAssertionPlanRepo->store($repeatedDrivingAssertionPlan); $this->init->em->flush(); $find = $this->init->repeatedDrivingAssertionPlanRepo->find($repeatedDrivingAssertionPlan->getId()); $this->assertEquals($find, $repeatedDrivingAssertionPlan); //monthly $repeatedDrivingAssertionMonthly = new RepeatedMonthlyDrivingAssertion(); $repeatedDrivingAssertionMonthly->setRelativeWeekAsText('first'); $repeatedDrivingAssertionMonthly->setWeekdayAsText('monday'); $this->init->repeatedDrivingAssertionRepo->store($repeatedDrivingAssertionMonthly); $repeatedDrivingAssertionPlan = RepeatedDrivingAssertionPlan::registerRepeatedAssertionPlan('test', new \DateTime(), 'monthly', true); $repeatedDrivingAssertionPlan->assignDriver($driver); $repeatedDrivingAssertionPlan->assignRepeatedDrivingAssertion($repeatedDrivingAssertionMonthly); $this->init->repeatedDrivingAssertionPlanRepo->store($repeatedDrivingAssertionPlan); $this->init->em->flush(); $find = $this->init->repeatedDrivingAssertionPlanRepo->find($repeatedDrivingAssertionPlan->getId()); $this->assertEquals($find, $repeatedDrivingAssertionPlan); }
/** * @param RepeatedDrivingAssertionRegisterDTO $dto * @return ArrayCollection */ public function repeatedRegisterDTOtoMonthlyDrivingAssertions(RepeatedDrivingAssertionRegisterDTO $dto) { $monthlyDrivingAssertions = new ArrayCollection(); /** @var ShiftSelectionDTO $shiftSelectionDTO */ foreach ($dto->getMonthlyShiftSelections() as $shiftSelectionDTO) { $selectionIdArray = $this->explodeMonthlySelectionId($shiftSelectionDTO->getSelectionId()); $monthlyDrivingAssertion = new RepeatedMonthlyDrivingAssertion(); $monthlyDrivingAssertion->setRelativeWeekAsText($selectionIdArray['relativeWeek']); $monthlyDrivingAssertion->setWeekdayAsText($selectionIdArray['weekday']); $monthlyDrivingAssertion->setShiftTypes($shiftSelectionDTO->getShiftSelection()); $monthlyDrivingAssertions->add($monthlyDrivingAssertion); } return $monthlyDrivingAssertions; }