/** ------------------------- * Validate the driving order DTO, errors are written to the array. * These are the "low hanging fruit" and easy to test. Later on in the * code some other special cases may be found and reported in $errors. * * @param DrivingOrderRegisterDTO $registerDTO * @param Passenger $passenger * @param array $errors * @return array */ private function validateDrivingOrderDto(DrivingOrderRegisterDTO $registerDTO, Passenger $passenger, &$errors) { if ($registerDTO->isRepeated == true) { $errors[] = 'drivingorder.form.error.unknown'; } if (null === $passenger) { $errors[] = 'drivingorder.form.error.unknown'; } else { if ($passenger->getisAuthorizedToRide() == false) { $errors[] = 'drivingorder.form.error.notAuthorized'; return $errors; } } if (null === $registerDTO->anchorDate) { $errors[] = 'drivingorder.form.error.emptyDate'; } else { $now = new \DateTime(); $now->setTime(0, 0, 0); if ($registerDTO->anchorDate < $now) { $errors[] = 'drivingorder.form.error.anchorDate'; } } if (empty($registerDTO->orderTime->outwardTime) and empty($registerDTO->orderTime->returnTime)) { $errors[] = 'drivingorder.form.error.empty'; } if ($registerDTO->additionalTime < 0) { $errors[] = 'drivingorder.form.error.extraMinutes'; } if ($registerDTO->compagnion < 0) { $errors[] = 'drivingorder.form.error.companions'; } }
private function passengerRemove(Passenger $passenger) { $id = $passenger->getId(); Passenger::removePassenger($passenger); $this->init->em->remove($passenger); $this->init->em->flush(); $this->assertEquals(null, $this->init->passengerRepo->find($id)); }
/** * @return mixed|void */ public function createFormRows() { /**@var $dto \Tixi\ApiBundle\Interfaces\PassengerRegisterDTO */ $dto = $this->dto; $this->basicFormRows[] = new FormRowView('id', 'passenger.field.id', $dto->person_id); $this->basicFormRows[] = new FormRowView('gender', 'person.field.gender', Person::constructGenderString($dto->gender)); $this->basicFormRows[] = new FormRowView('firstname', 'person.field.firstname', $dto->firstname); $this->basicFormRows[] = new FormRowView('lastname', 'person.field.lastname', $dto->lastname); $this->basicFormRows[] = new FormRowView('telephone', 'person.field.telephone', $dto->telephone); if (!empty($dto->building)) { $this->basicFormRows[] = new FormRowView('building', 'address.field.building', $dto->building); } $this->basicFormRows[] = new FormRowView('address', 'address.field.lookahead', $dto->lookaheadaddress->addressDisplayName); $this->basicFormRows[] = new FormRowView('isInWheelChair', 'passenger.field.isinwheelchair', Passenger::constructIsInWheelChairString($dto->isInWheelChair)); $this->basicFormRows[] = new FormRowView('hasMonthlyBilling', 'passenger.field.payment', Passenger::constructMonthlyBillingString($dto->hasMonthlyBilling)); $this->basicFormRows[] = new FormRowView('insurances', 'passenger.field.insurance', Passenger::constructInsurancesString($dto->insurances)); $this->basicFormRows[] = new FormRowView('notice', 'passenger.field.notice', $dto->notice); if (!empty($dto->entryDate)) { $this->expandedFormRows[] = new FormRowView('entrydate', 'person.field.entrydate', $dto->entryDate->format('d.m.Y')); } if (!empty($dto->birthday)) { $this->expandedFormRows[] = new FormRowView('birthday', 'person.field.birthday', $dto->birthday->format('d.m.Y')); } if (!empty($dto->birthday)) { $this->expandedFormRows[] = new FormRowView('age', 'person.field.age', $this->getAge($dto->birthday)); } $this->expandedFormRows[] = new FormRowView('extraminutes', 'person.field.extraminutes', $dto->extraMinutes); }
public function testCustodianCRUD() { $address = Address::registerAddress('Teststrasse 142', '6360', 'Cham', 'Schweiz'); $this->init->addressRepo->store($address); $custodian = Custodian::registerCustodian('f', 'Toranto', 'Testinger', '041 324 33 22', $address, 'Herro', '*****@*****.**', new \DateTime(), new \DateTime(), 5, 'alles nur ein Test', 'und auch Notizen'); $passenger = Passenger::registerPassenger('f', 'Toranto', 'Testinger', '041 324 33 22', $address, 'Herro', true, false, '*****@*****.**', new \DateTime(), new \DateTime(), 5, 'alles nur ein Test', 'und auch Notizen'); $passenger2 = Passenger::registerPassenger('m', 'Toranto2', 'Testinger2', '041 324 33 222', $address, 'Herr', true, false, '*****@*****.**', new \DateTime(), new \DateTime(), 5, 'alles nur ein Test', 'und auch Notizen'); $custodian->assignPassenger($passenger); $custodian->assignPassenger($passenger2); $passenger->assignCustodian($custodian); $this->init->custodianRepo->store($custodian); $this->init->passengerRepo->store($passenger); $this->init->passengerRepo->store($passenger2); $this->init->em->flush(); $custodianFind = $this->init->custodianRepo->find($custodian->getId()); $this->assertEquals($custodian, $custodianFind); $this->custodianRemove($custodian); }
/** * @param Passenger $passenger * @return PassengerListDTO */ public function passengerToPassengerListDTO(Passenger $passenger) { $passengerListDTO = new PassengerListDTO(); $passengerListDTO->id = $passenger->getId(); $passengerListDTO->gender = $passenger->getGenderAsString(); $passengerListDTO->firstname = $passenger->getFirstname(); $passengerListDTO->telephone = $passenger->getTelephone(); $passengerListDTO->lastname = $passenger->getLastname(); $passengerListDTO->street = $passenger->getAddress()->getStreet(); $passengerListDTO->city = $passenger->getAddress()->getCity(); $passengerListDTO->isInWheelChair = $passenger->getIsInWheelChairAsString(); $passengerListDTO->hasMonthlyBilling = $passenger->getMonthlyBillingAsString(); $passengerListDTO->insurances = $passenger->getInsurancesAsString(); return $passengerListDTO; }
/** ------------------------- * Create a notice (one or more warnings) for a passenger * * @param Passenger $passenger * @return mixed */ protected function constructNotice(Passenger $passenger) { $tr = $this->container->get('translator'); $notice = $passenger->getNotice(); $notAuthorized = $passenger->getisAuthorizedToRide() ? null : $tr->trans('drivingorder.form.error.notAuthorized'); $linefeed = (isset($notice) and isset($notAuthorized)) ? "\n" : null; return $notAuthorized . $linefeed . $notice; }
public function testDrivingOrderCRUD() { $addressFrom = $this->init->createTestAddressBaar(); $addressTo = $this->init->createTestAddressGoldau(); $passenger = Passenger::registerPassenger('m', 'Arthuro', 'Benatone', '+418182930', $addressFrom); $this->init->passengerRepo->store($passenger); $date = $this->init->dateTimeService->convertDateTimeStringToUTCDateTime('20.05.2014 00:00'); $time = $this->init->dateTimeService->convertDateTimeStringToUTCDateTime('20.05.2014 15:05'); $route = Route::registerRoute($addressFrom, $addressTo, 0, 0); $route->setDuration(15); $route->setDistance(6); $this->init->routeRepo->store($route); $drivingOrder = DrivingOrder::registerDrivingOrder($passenger, $date, $time, 2, 'möchte nicht hinten sitzen'); $drivingOrder->assignRoute($route); $passenger->assignDrivingOrder($drivingOrder); $drivingOrder->assignPassenger($passenger); $this->init->drivingOrderRepo->store($drivingOrder); $this->init->em->flush(); $this->assertNotNull($this->init->drivingOrderRepo->find($drivingOrder->getId())); //TimePeriod from start day of month to next start day of month $monthsAgo = 3; $monthDate = new \DateTime('today'); $monthDate->modify('+' . $monthsAgo . ' month'); $monthDate->format('first day of this month'); $workingMonth = WorkingMonth::registerWorkingMonth($monthDate); $workingMonth->createWorkingDaysForThisMonth(); foreach ($workingMonth->getWorkingDays() as $wd) { $this->init->workingDayRepo->store($wd); } $this->init->workingMonthRepo->store($workingMonth); $workingDays = $workingMonth->getWorkingDays(); /**@var $shiftTypes ShiftType[] */ $shiftTypes = $this->init->shiftTypeRepo->findAllActive(); //create workingDays shifts, assign them drivingpools, get amount of needed drivers /** @var $workingDay WorkingDay */ foreach ($workingDays as $workingDay) { /** @var $shiftType ShiftType */ foreach ($shiftTypes as $shiftType) { $shift = Shift::registerShift($workingDay, $shiftType); $shift->setAmountOfDrivers(16); $workingDay->assignShift($shift); for ($i = 1; $i <= $shift->getAmountOfDrivers(); $i++) { $drivingPool = DrivingPool::registerDrivingPool($shift); $shift->assignDrivingPool($drivingPool); $this->init->drivingPoolRepo->store($drivingPool); } $this->init->shiftRepo->store($shift); } $this->init->workingDayRepo->store($workingDay); } $this->init->em->flush(); $this->assertNotNull($this->init->workingMonthRepo->find($workingMonth->getId())); $drivingAssertionPlans = $this->init->repeatedDrivingAssertionPlanRepo->findPlanForDate(new \DateTime()); $this->assertNotNull($drivingAssertionPlans); $drivingPools = array(); foreach ($workingMonth->getWorkingDays() as $wd) { foreach ($wd->getShifts() as $s) { foreach ($s->getDrivingPools() as $dp) { array_push($drivingPools, $dp); } } } foreach ($drivingAssertionPlans as $drivingAssertionPlan) { $assertions = $drivingAssertionPlan->getRepeatedDrivingAssertions(); foreach ($assertions as $assertion) { if ($assertion->matching($shift)) { echo "\nmatches\n"; $drivingPool = DrivingPool::registerDrivingPool($shift); $this->init->drivingPoolRepo->store($drivingPool); } } } $vehicles = $this->init->vehicleRepo->findAll(); /**@var $vehicle Vehicle */ foreach ($vehicles as $vehicle) { foreach ($vehicle->getServicePlans() as $sp) { } } }
/** * @param AbsentRegisterDTO $absentDTO * @param Passenger $passenger */ protected function registerOrUpdateAbsentToPassenger(AbsentRegisterDTO $absentDTO, Passenger $passenger) { $absentRepository = $this->get('absent_repository'); $assembler = $this->get('tixi_api.assemblerabsent'); if (empty($absentDTO->id)) { $absent = $assembler->registerDTOtoNewAbsent($absentDTO); $passenger->assignAbsent($absent); $absentRepository->store($absent); } else { /**@var $absent Absent */ $absent = $absentRepository->find($absentDTO->id); $assembler->registerDTOtoAbsent($absentDTO, $absent); } }
/** * @param Passenger $passenger */ public static function removePassenger(Passenger $passenger) { $passenger->removePerson(); }