You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Carbon library has a very useful and easy to use feature to travel in time inside your tests:
$knownDate=Carbon::create(2001,5,21,12);// create testing date
Carbon::setTestNow($knownDate);// set the mock (of course this could be a real mock object)
This works with Laravel in most pieces of code, but not all. Because php built function time() is used 16 times in Laravel code base (I'm having issues with Cookie expire time generation).
As Carbon is a Laravel dependency, I thinks is possible to replace time() calls for Carbon equivalent. This way, time travel would be possible in Laravel tests. I think this would be awesome!
What do you think?
The text was updated successfully, but these errors were encountered:
dmoreno
changed the title
Use of Carbon::setTestNow
Time travel in tests
Jul 8, 2016
Carbon library has a very useful and easy to use feature to travel in time inside your tests:
This works with Laravel in most pieces of code, but not all. Because php built function
time()
is used 16 times in Laravel code base (I'm having issues with Cookie expire time generation).As Carbon is a Laravel dependency, I thinks is possible to replace
time()
calls for Carbon equivalent. This way, time travel would be possible in Laravel tests. I think this would be awesome!What do you think?
The text was updated successfully, but these errors were encountered: