File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -409,11 +409,15 @@ Clock Mocking
409409~~~~~~~~~~~~~
410410
411411The :class: `Symfony\\ Bridge\\ PhpUnit\\ ClockMock ` class provided by this bridge
412- allows you to mock the PHP's built-in time functions ``time() ``,
413- ``microtime() ``, ``sleep() ``, ``usleep() `` and ``gmdate() ``. Additionally the function
414- ``date() `` is mocked so it uses the mocked time if no timestamp is specified.
412+ allows you to mock the PHP's built-in time functions ``time() ``, ``microtime() ``,
413+ ``sleep() ``, ``usleep() `` and ``gmdate() ``. Additionally the function ``date() ``
414+ is mocked so it uses the mocked time if no timestamp is specified.
415+
415416Other functions with an optional timestamp parameter that defaults to ``time() ``
416- will still use the system time instead of the mocked time.
417+ will still use the system time instead of the mocked time. This means that you
418+ may need to change some code in your tests. For example, instead of ``new DateTime() ``,
419+ you should use ``DateTime::createFromFormat('U', time()) `` to use the mocked
420+ ``time() `` function.
417421
418422To use the ``ClockMock `` class in your test, add the ``@group time-sensitive ``
419423annotation to its class or methods. This annotation only works when executing
You can’t perform that action at this time.
0 commit comments