Exemple #1
0
 public function testOpenShiftForToday()
 {
     $e = new Employee();
     $e->openShiftForToday();
     assertThat($e->shiftOpenToday(), is(true));
     $e->closeOpenShift();
     assertThat($e->shiftOpenToday(), is(false));
     $e->openShiftForToday();
     assertThat($e->getWorktimes()->count(), is(2));
 }
Exemple #2
0
 /**
  * @param Employee $employee
  */
 public function loginEmployee(Employee $employee)
 {
     if ($employee->getWorkingNow() === false) {
         $employee->closeOpenShift();
         $employee->openShiftForToday();
         $employee->setWorkingNow(true);
         $this->setStatus(200, 'New worktime shift open');
     } else {
         if ($employee->shiftOpenToday()) {
             throw new HttpException(412, 'Employee currently at work. No action taken.');
         } else {
             $employee->closeOpenShift();
             $employee->openShiftForToday();
             $this->setStatus(200, 'Worktime truncated. New shift re-opened.');
         }
     }
     $this->persist($employee);
 }