public function testCreate() { $user = new User(); $task = new Task(); $timeTrackingRecord = new Tracker($user, $task); $this->assertNull($timeTrackingRecord->getId()); $this->assertEquals($user, $timeTrackingRecord->getUser()); $this->assertEquals($task, $timeTrackingRecord->getTask()); $this->assertGreaterThanOrEqual(new \DateTime('now', new \DateTimeZone('UTC')), $timeTrackingRecord->getDateStarted()); }
public function testStopTracking() { $user = new User(); $task = new Task(); $waitTimeInSeconds = 2; $tracker = new Tracker($user, $task); sleep($waitTimeInSeconds); $timeSpent = new TimeSpent($waitTimeInSeconds); $worklog = new Worklog($timeSpent, $tracker->getDateStarted(), $task, $user); $this->trackerRepository->expects($this->once())->method('retrieveUserTracker')->with($user)->will($this->returnValue($tracker)); $this->trackerRepository->expects($this->once())->method('removeTracker')->with($tracker); $this->timeSpentFactory->expects($this->once())->method('create')->with($tracker->getSpentSeconds())->will($this->returnValue($timeSpent)); $this->worklogFactory->expects($this->once())->method('create')->with($timeSpent, $tracker->getDateStarted(), $task, $user)->will($this->returnValue($worklog)); $this->worklogRepository->expects($this->once())->method('save')->with(); $this->service->stopTracking($user); }