R
R
Romi2022-04-03 13:34:33
PHPUnit
Romi, 2022-04-03 13:34:33

How to simulate the system time of the server when testing (Laravel + phpunit)?

I have a piece of the program that works differently depending on the time and date,

how can this be (and should) be written in Laravel tests?

how to simulate different date and time?

thank.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
TheAndrey7, 2022-04-03
@romicohen

In principle, if you use Carbon everywhere, it also has the ability to set a fake date.
https://carbon.nesbot.com/docs/#api-testing

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question