With CakePHP 3, I'm using the built in class Cake\I18n\Time
to calculate the difference in time from an API response and the current time. The results are getting stored for a unit test, but I don't know how to set what the current time is, so the expected results keep changing.
Here's the unit I'm trying to test:
$apiTime = Time::createFromTimestamp($apiTimestamp);
// Get the time the prediction was generated
$currentTime = Time::now();
return (int)(($apiTime->getTimestamp() - $currentTime->getTimestamp()) / 60);
So, is there any way that I can set the current time? That way I would be able to actually know what the expected results are.
Aucun commentaire:
Enregistrer un commentaire