Example #1
0
 private function driverCreateAbsent(Driver $driver)
 {
     $absent = Absent::registerAbsent('Ferien', new \DateTime('2014-11-12'), new \DateTime('2014-12-12'));
     $absent2 = Absent::registerAbsent('Ferien da', new \DateTime('2015-11-12'), new \DateTime('2015-12-12'));
     $this->init->absentRepo->store($absent);
     $this->init->absentRepo->store($absent2);
     $driver->assignAbsent($absent);
     $driver->assignAbsent($absent2);
     $this->init->driverRepo->store($driver);
     $this->init->em->flush();
     $found = false;
     $absents = $driver->getAbsents();
     foreach ($absents as $a) {
         if ($a->getId() == $absent2->getId()) {
             $found = true;
         }
     }
     $this->assertTrue($found);
     $this->assertCount(2, $absents);
 }
 /**
  * @param AbsentRegisterDTO $absentDTO
  * @param Driver $driver
  */
 protected function registerOrUpdateAbsentToDriver(AbsentRegisterDTO $absentDTO, Driver $driver)
 {
     $absentRepository = $this->get('absent_repository');
     $assembler = $this->get('tixi_api.assemblerabsent');
     /** @var DrivingAssertionManagement $drivingAssertionService */
     $drivingAssertionService = $this->get('tixi_app.drivingassertionmanagement');
     if (empty($absentDTO->id)) {
         $absent = $assembler->registerDTOtoNewAbsent($absentDTO);
         $driver->assignAbsent($absent);
         $absentRepository->store($absent);
     } else {
         $absent = $absentRepository->find($absentDTO->id);
         $assembler->registerDTOtoAbsent($absentDTO, $absent);
     }
     $drivingAssertionService->handleNewOrChangedAbsent($driver);
 }