Dmitriy_ru's avatar

How can I test time based components? (mock time)

How can I test time based components. For example I debug component that will trigger some event only if the time is "right".

I would like to:

  • set time manually
  • call component
  • assert that action was called or not
  • set another time and so on.

But internally component is based on time() or Carbon component. What is the best way to change time during the tests?

0 likes
1 reply

Please or to participate in this conversation.