diff --git a/components/phpunit_bridge.rst b/components/phpunit_bridge.rst index 189b608037a..c5332a86476 100644 --- a/components/phpunit_bridge.rst +++ b/components/phpunit_bridge.rst @@ -165,16 +165,27 @@ The :class:`Symfony\\Bridge\\PhpUnit\\ClockMock` class provided by this bridge allows you to mock the PHP's built-in time functions ``time()``, ``microtime()``, ``sleep()`` and ``usleep()``. -To use the ``ClockMock`` class in your test, you can: +To use the ``ClockMock`` class in your test, add the ``@group time-sensitive`` +annotation to its class or methods. This annotation only works when executing +PHPUnit using the ``vendor/bin/simple-phpunit`` script or when registering the +following listener in your PHPUnit configuration: -* (**Recommended**) Add the ``@group time-sensitive`` annotation to its class or - method; +.. code-block:: xml + + + + + + + +.. note:: -* Register it manually by calling ``ClockMock::register(__CLASS__)`` and - ``ClockMock::withClockMock(true)`` before the test and - ``ClockMock::withClockMock(false)`` after the test. + If you don't want to use the ``@group time-sensitive`` annotation, you can + register the ``ClockMock`` class manually by calling + ``ClockMock::register(__CLASS__)`` and ``ClockMock::withClockMock(true)`` + before the test and ``ClockMock::withClockMock(false)`` after the test. -As a result, the following is guarenteed to work and is no longer a transient +As a result, the following is guaranteed to work and is no longer a transient test:: use Symfony\Component\Stopwatch\Stopwatch;