public function testGetSpentSeconds()
 {
     $user = new User();
     $task = new Task();
     $timeTrackingRecord = new Tracker($user, $task);
     $workTimeInSeconds = 2;
     sleep($workTimeInSeconds);
     $timeSpent = $timeTrackingRecord->getSpentSeconds();
     $this->assertGreaterThanOrEqual($workTimeInSeconds, $timeSpent);
 }
 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);
 }