/**
  * @test
  */
 public function shift_times()
 {
     $now = Carbon::now();
     $calculator = new ShiftTimeCalculator();
     list($daystart, $dayend) = $calculator->shiftTimes('day');
     list($nightstart, $nightend) = $calculator->shiftTimes('night');
     $day_shift_start = $now->copy()->setTime(6, 0, 0);
     $day_shift_end = $now->copy()->setTime(18, 0, 0);
     $night_shift_start = $now->copy()->setTime(18, 0, 0);
     $night_shift_end = $now->copy()->addDay()->setTime(6, 0, 0);
     $this->assertEquals($day_shift_start, $daystart, "Day Shift Start");
     $this->assertEquals($day_shift_end, $dayend, "Day Shift End");
     $this->assertEquals($night_shift_start, $nightstart, "Night Shift Start");
     $this->assertEquals($night_shift_end, $nightend, "Night Shift End");
 }
 /**
  * Determine meter count for provided shift string ('day' | 'night')
  *
  * @param $shift
  * @return int
  */
 protected function countMetersPerShift($shift)
 {
     $shiftCalculator = new ShiftTimeCalculator();
     list($startTime, $endTime) = $shiftCalculator->shiftTimes($shift);
     $printingJobs = $this->shiftJobs($startTime);
     //        foreach ($printingJobs as $job) {
     //            var_dump($job->job_cards_print_priority . " " . $shift);
     //        }
     $shiftMeters = 0;
     $cumulativeTime = $startTime;
     $nextJob = $printingJobs->shift();
     while ($cumulativeTime->lt($endTime) && $printingJobs->count() > 0) {
         //            var_dump($nextJob->job_cards_print_date->toDateTimeString());
         //            var_dump($cumulativeTime->toDateTimeString());
         $remainingSetupMinutes = $this->remainingSetupMinutesInShift($nextJob, $cumulativeTime);
         //            var_dump($remainingSetupMinutes);
         $cumulativeTime->addMinutes($remainingSetupMinutes);
         if ($cumulativeTime->lt($endTime)) {
             $remainingRunMinutes = $this->remainingRunMinutesInShift($nextJob, $cumulativeTime);
             //                var_dump($remainingRunMinutes . "remain");
             $cumulativeTime->addMinutes($remainingRunMinutes);
             $shiftMeters = $shiftMeters + $nextJob->printing_speed_mpm * $remainingRunMinutes;
             $nextJob = $printingJobs->shift();
         }
         //            var_dump($cumulativeTime->toDateTimeString());
     }
     return $shiftMeters;
 }