public function testShiftOpenToday() { $worktime1 = (new WorkTime())->setStart(new \DateTime('2014-10-01'))->setEnd(new \DateTime('2014-10-01')); $worktime2 = (new WorkTime())->setStart(new \DateTime('2013-10-01'))->setEnd(new \DateTime('2013-10-01')); $worktime3 = (new WorkTime())->setStart(new \DateTime('2015-10-01'))->setEnd(new \DateTime('2015-10-01')); $e = new Employee(); $e->addWorktime($worktime1)->addWorktime($worktime2)->addWorktime($worktime3); assertThat($e->shiftOpenToday(), is(false)); $e->addWorktime((new WorkTime())->setStart(new \DateTime())); assertThat($e->shiftOpenToday(), is(true)); $e->closeOpenShift(); assertThat($e->shiftOpenToday(), is(false)); }
public function testLoginEmployeeForgottenLogout() { $employee = new Employee(); $employee->setWorkingNow(true); $worktime1 = (new WorkTime())->setStart(new \DateTime('2014-10-01'))->setEnd(null); // basically forgot to logout $employee->addWorktime($worktime1); $this->tested->loginEmployee($employee); assertThat($employee->getWorkingNow(), is(true)); assertThat($this->tested->getCode(), is(200)); assertThat($this->tested->getMessage(), is('Worktime truncated. New shift re-opened.')); }