private function createShiftType($name) { $shiftType = ShiftType::registerShiftType($name, new \DateTime(), new \DateTime()); $current = $this->init->shiftTypeRepo->findOneBy(array('name' => $name)); if (empty($current)) { $this->init->shiftTypeRepo->store($shiftType); return $shiftType; } return $current; }
public function testShiftCRUD() { $from = \DateTime::createFromFormat('H:i', '10:00'); $to = \DateTime::createFromFormat('H:i', '14:00'); $shiftType = ShiftType::registerShiftType('Test123', $from, $to); $this->init->shiftTypeRepo->store($shiftType); $this->init->em->flush(); $find = $this->init->shiftTypeRepo->find($shiftType->getId()); $this->assertEquals($shiftType, $find); $workDay = WorkingDay::registerWorkingDay(new \DateTime()); $this->init->workingDayRepo->store($workDay); $shift = Shift::registerShift($workDay, $shiftType, 12); $this->init->shiftRepo->store($shift); $this->init->em->flush(); $find = $this->init->shiftRepo->find($shift->getId()); $this->assertEquals($shift, $find); }
/** * @param ShiftTypeRegisterDTO $shiftTypeDTO * @return ShiftType */ public function registerDTOtoNewShiftType(ShiftTypeRegisterDTO $shiftTypeDTO) { $shiftType = ShiftType::registerShiftType($shiftTypeDTO->name, $shiftTypeDTO->start, $shiftTypeDTO->end, $shiftTypeDTO->memo); return $shiftType; }