/** * @param array with startingHour and finishHOur * @param array with expected results * * @dataProvider providertestarrayIntervaloHoras */ public function testarrayIntervaloHoras(array $time, array $expectedResult) { $intervaloHoras = TimeMachine::arrayIntervaloHoras($time['startingHour'], $time['finishHour'], $time['interval']); $numEltos = count($intervaloHoras); $numEltos1 = count($expectedResult); $this->assertEquals($numEltos, $numEltos1); for ($i = 0; $i < $numEltos; $i++) { $this->assertEquals($expectedResult[$i], $intervaloHoras[$i]); } }
private function putSchedulesInWeekarray($semana, array $schedules, $interval) { $diasSemana = array('Lunes', 'Martes', 'Miercoles', 'Jueves', 'Viernes', 'Sabado', 'Domingo'); foreach ($schedules as $schedule) { $h = array('minutes' => (int) $schedule['startingHour']->format('i'), 'hours' => (int) $schedule['startingHour']->format('H')); $hf = array('minutes' => (int) $schedule['finishHour']->format('i'), 'hours' => (int) $schedule['finishHour']->format('H')); // Ojo, el redondeo de horas falla $hr = TimeMachine::roundMinutes($h); // obtengo la hora inicio redondeada $hfr = TimeMachine::roundMinutes($hf); // obtengo la hora final redondeada $intervaloHoras = TimeMachine::arrayIntervaloHoras($hr, $hfr, $interval); $d = $diasSemana[date('N', strtotime($schedule['scheduleDate']->format('Y-m-d'))) - 1]; foreach ($intervaloHoras as $value) { $semana[$d][$value]['nombreCita'] = $schedule['name'] . " " . $schedule['lastName']; $semana[$d][$value]['idCita'] = $schedule['id']; $semana[$d][$value]['idAppointment'] = $schedule['appointment']; } } return $semana; }