/**
  * @test
  */
 public function thatLogsWork()
 {
     $timeSpentInputString = '10m';
     $timeSpentInSeconds = 600;
     $dateStarted = new \DateTime('now');
     $description = 'DESC';
     $task = new Task();
     $user = new User();
     $timeSpent = new TimeSpent($timeSpentInSeconds);
     $worklog = new Worklog($timeSpent, $dateStarted, $task, $user, $description);
     $this->timeSpentFactory->expects($this->once())->method('createFromString')->with('10m')->will($this->returnValue($timeSpent));
     $this->worklogFactory->expects($this->once())->method('create')->with()->will($this->returnValue($worklog));
     $this->worklogRepository->expects($this->once())->method('save')->with($worklog);
     $this->service->logWork($timeSpentInputString, $dateStarted, $task, $user, $description);
 }
 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);
 }