arth / time-machine
Abstraction for current datetime
v2.0.0
2020-09-02 09:22 UTC
Requires (Dev)
- phpunit/php-code-coverage: ^6.0.7
- phpunit/phpunit: ^7.5
This package is auto-updated.
Last update: 2024-10-29 05:16:47 UTC
README
Module for application time control for testing purpose.
Usage:
composer req arth/time-machine
- replace all
new DateTime('now')
and analogues withArth\Utils\TimeMachine::getInstance()->getNow()
- in tests call
Arth\Utils\TimeMachine::getInstance()->setNow($dt)
with necessary $dt object for time shift.
Changelog
v1.0.0
- getNow()/setNow(DateTimeInterface)
- setFreezedMode(bool) - is time tick between getNow() calls?
- date2ts(DateTimeInterface)/ts2date($ts) with correct microseconds handling