Skip to content

Commit f22904d

Browse files
committed
minor #10432 [Bridge/PhpUnit] Add documentation about mocking date() in ClockMock (Dominic Tubach)
This PR was submitted for the master branch but it was merged into the 4.2 branch instead (closes #10432). Discussion ---------- [Bridge/PhpUnit] Add documentation about mocking date() in ClockMock Fixes #10287. Commits ------- 51a3924 [Bridge/PhpUnit] Add documentation about mocking date() in ClockMock
2 parents 181861e + 51a3924 commit f22904d

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)