How to write php unit test. The code is working properly but as I am new to php unit testing need help to generate a php unit test for it.
<?php
$duration = 60;
$cleanup = 0;
$start = "10:00";
$end = "18:00";
function timeslots($duration,$cleanup,$start,$end){
$start = new DateTime($start);
$end = new DateTime($end);
$interval = new DateInterval("PT".$duration."M");
$cleanupInterval = new DateInterval("PT".$cleanup."M");
$slots = array();
for($intStart = $start;$intStart<$end;$intStart->add($interval)->add($cleanupInterval)){
$endPeriod = clone $intStart;
$endPeriod->add($interval);
if($endPeriod>$end){
break;
}
$slots[] = $intStart->format("H:iA")."-".$endPeriod->format("H:iA");
}
return $slots;
}
?>
Aucun commentaire:
Enregistrer un commentaire