@@ -18,9 +18,9 @@ It comes with the following features:
18
18
19
19
* Displays the stack trace of a deprecation on-demand;
20
20
21
- * Provides a ``ClockMock `` helper class for time-sensitive tests.
21
+ * Provides a ``ClockMock `` and `` DnsMock `` helper classes for time or network -sensitive tests.
22
22
23
- * Provides a modified version of phpunit that does not embed ``symfony/yaml `` nor
23
+ * Provides a modified version of PHPUnit that does not embed ``symfony/yaml `` nor
24
24
``prophecy `` to prevent any conflicts with these dependencies.
25
25
26
26
Installation
@@ -133,6 +133,28 @@ completely disable the deprecation helper. This is useful to make use of the
133
133
rest of features provided by this component without getting errors or messages
134
134
related to deprecations.
135
135
136
+ Write Assertions about Deprecations
137
+ -----------------------------------
138
+
139
+ When adding deprecations to your code, you might like writing tests that verify
140
+ that they are triggered as required. To do so, the bridge provides the
141
+ ``@expectedDeprecation `` annotation that you can use on your test methods.
142
+ It requires you to pass the expected message, given in the same format than for
143
+ the `PHPUnit's assertStringMatchesFormat() `_ method. If you expect more than one
144
+ deprecation message for a given test method, you can use the annotation several
145
+ times (order matters)::
146
+
147
+ /**
148
+ * @group legacy
149
+ * @expectedDeprecation This "%s" method is deprecated.
150
+ * @expectedDeprecation The second argument of the "%s" method is deprecated.
151
+ */
152
+ public function testDeprecatedCode()
153
+ {
154
+ @trigger_error('This "Foo" method is deprecated.', E_USER_DEPRECATED);
155
+ @trigger_error('The second argument of the "Bar" method is deprecated.', E_USER_DEPRECATED);
156
+ }
157
+
136
158
Time-sensitive Tests
137
159
--------------------
138
160
@@ -340,7 +362,7 @@ its ``bin/simple-phpunit`` command. It has the following features:
340
362
341
363
* Does not embed ``symfony/yaml `` nor ``prophecy `` to prevent any conflicts with
342
364
these dependencies;
343
- * Uses PHPUnit 4.8 when run with PHP <=5.5 and PHPUnit 5.1 when run with PHP >=5.6;
365
+ * Uses PHPUnit 4.8 when run with PHP <=5.5 and PHPUnit 5.3 when run with PHP >=5.6;
344
366
* Collects and replays skipped tests when the ``SYMFONY_PHPUNIT_SKIPPED_TESTS ``
345
367
env var is defined: the env var should specify a file name that will be used for
346
368
storing skipped tests on a first run, and replay them on the second run;
@@ -358,8 +380,19 @@ If you have installed the bridge through Composer, you can run it by calling e.g
358
380
359
381
$ vendor/bin/simple-phpunit
360
382
383
+ .. tip ::
384
+
385
+ Set the ``SYMFONY_PHPUNIT_VERSION `` env var to e.g. ``5.5 `` to change the
386
+ base version of PHPUnit to ``5.5 `` instead of the default ``5.3 ``.
387
+
388
+ .. tip ::
389
+
390
+ Set the ``SYMFONY_PHPUNIT_REMOVE `` env var to ``symfony/yaml `` if you need
391
+ ``prophecy `` but not ``symfony/yaml ``.
392
+
361
393
.. _PHPUnit : https://phpunit.de
362
394
.. _`PHPUnit event listener` : https://phpunit.de/manual/current/en/extending-phpunit.html#extending-phpunit.PHPUnit_Framework_TestListener
395
+ .. _`PHPUnit's assertStringMatchesFormat()` : https://phpunit.de/manual/current/en/appendixes.assertions.html#appendixes.assertions.assertStringMatchesFormat
363
396
.. _`PHP error handler` : http://php.net/manual/en/book.errorfunc.php
364
397
.. _`environment variable` : https://phpunit.de/manual/current/en/appendixes.configuration.html#appendixes.configuration.php-ini-constants-variables
365
398
.. _Packagist : https://packagist.org/packages/symfony/phpunit-bridge
0 commit comments