Can I “Mock” time in PHPUnit?

后端 未结 11 530
梦谈多话
梦谈多话 2020-11-29 01:53

... not knowing if \'mock\' is the right word.

Anyway, I have an inherited code-base that I\'m trying to write some tests for that are time-based. Trying not to be <

11条回答
  •  北荒
    北荒 (楼主)
    2020-11-29 02:19

    For those of you working with symfony (>= 2.8): Symfony's PHPUnit Bridge includes a ClockMock feature that overrides the built-in methods time, microtime, sleep and usleep.

    See: http://symfony.com/doc/2.8/components/phpunit_bridge.html#clock-mocking

提交回复
热议问题