@@ -151,20 +151,20 @@ being in a month or another.
151
151
Writing Time-Sensitive Tests
152
152
----------------------------
153
153
154
- The Clock component provides another trait, this one easing you the writing of time-sensitive
155
- tests: the :class: `Symfony\\ Component\\ Clock\\ Test\\ ClockSensitiveTrait `. The purpose
156
- of this trait is to provide methods to freeze time and restore the global clock after
157
- each test.
154
+ The Clock component provides another trait, called :class: `Symfony\\ Component\\ Clock\\ Test\\ ClockSensitiveTrait `,
155
+ to help you write time-sensitive tests. This trait provides methods to freeze
156
+ time and restore the global clock after each test.
158
157
159
- To interact with the mocked clock in your tests, you will have to use the ``ClockSensitiveTrait::mockTime() ``
160
- method . This method accepts many types as its only argument:
158
+ Use the ``ClockSensitiveTrait::mockTime() `` method to interact with the mocked
159
+ clock in your tests . This method accepts different types as its only argument:
161
160
162
- * A string, which can be a date or an interval. Examples: ``1996-07-01 `` or ``+2 days ``
163
- * A ``DateTimeImmutable `` to set the clock at
164
- * A boolean, to freeze or restore the global clock
161
+ * A string, which can be a date to set the clock at (e.g. ``1996-07-01 ``) or an
162
+ interval to modify the clock (e.g. ``+2 days ``);
163
+ * A ``DateTimeImmutable `` to set the clock at;
164
+ * A boolean, to freeze or restore the global clock.
165
165
166
- Let's say you want to test the method ``MonthSensitive::isWinterMonth() `` of the above example.
167
- An approach of the test class could be written this way ::
166
+ Let's say you want to test the method ``MonthSensitive::isWinterMonth() `` of the
167
+ above example. This is how you can write that test ::
168
168
169
169
namespace App\Tests\TimeUtils;
170
170
@@ -197,10 +197,10 @@ An approach of the test class could be written this way::
197
197
}
198
198
}
199
199
200
- It doesn't matter which time of the year you are running this test, it will always behave
201
- the same way. By combining the :class: `Symfony\\ Component\\ Clock\\ ClockAwareTrait ` and
202
- :class: `Symfony\\ Component\\ Clock\\ Test\\ ClockSensitiveTrait `, you have full control on
203
- your time-sensitive code's behavior.
200
+ This test will behave the same no matter which time of the year you run it.
201
+ By combining the :class: `Symfony\\ Component\\ Clock\\ ClockAwareTrait ` and
202
+ :class: `Symfony\\ Component\\ Clock\\ Test\\ ClockSensitiveTrait `, you have full
203
+ control on your time-sensitive code's behavior.
204
204
205
205
.. versionadded :: 6.3
206
206
0 commit comments