Skip to content

Commit 51a3924

Browse files
Dominic Tubachxabbuh
authored andcommitted
[Bridge/PhpUnit] Add documentation about mocking date() in ClockMock
1 parent 181861e commit 51a3924

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

components/phpunit_bridge.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,10 @@ Clock Mocking
330330

331331
The :class:`Symfony\\Bridge\\PhpUnit\\ClockMock` class provided by this bridge
332332
allows you to mock the PHP's built-in time functions ``time()``,
333-
``microtime()``, ``sleep()`` and ``usleep()``.
333+
``microtime()``, ``sleep()`` and ``usleep()``. Additionally the function
334+
``date()`` is mocked so it uses the mocked time if no timestamp is specified.
335+
Other functions with an optional timestamp parameter that defaults to ``time()``
336+
will still use the system time instead of the mocked time.
334337

335338
To use the ``ClockMock`` class in your test, add the ``@group time-sensitive``
336339
annotation to its class or methods. This annotation only works when executing

0 commit comments

Comments
 (0)