Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5.3k
[PhpUnitBridge] Doc for @expectedDeprecation & new configuration env vars#7074
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -18,9 +18,9 @@ It comes with the following features: | ||
| * Displays the stack trace of a deprecation on-demand; | ||
| * Provides a ``ClockMock``and ``DnsMock``helperclasses for time or network-sensitive tests. | ||
| * Provides a modified version ofPHPUnit that does not embed ``symfony/yaml`` nor | ||
| ``prophecy`` to prevent any conflicts with these dependencies. | ||
| Installation | ||
| @@ -133,6 +133,28 @@ completely disable the deprecation helper. This is useful to make use of the | ||
| rest of features provided by this component without getting errors or messages | ||
| related to deprecations. | ||
| Write Assertions about Deprecations | ||
| ----------------------------------- | ||
| When adding deprecations to your code, you might like writing tests that verify | ||
| that they are triggered as required. To do so, the bridge provides the | ||
| ``@expectedDeprecation`` annotation that you can use on your test methods. | ||
| It requires you to pass the expected message, given in the same format than for | ||
| the `PHPUnit's assertStringMatchesFormat()`_ method. If you expect more than one | ||
| deprecation message for a given test method, you can use the annotation several | ||
| times (order matters):: | ||
| /** | ||
| * @group legacy | ||
| * @expectedDeprecation This "%s" method is deprecated. | ||
| * @expectedDeprecation The second argument of the "%s" method is deprecated. | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. is the order of annotations important ? If they must be in the same order than the triggered deprecation, this should be documented (or changed in the code) MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. yes it is, open for discussion for sure MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Note added above | ||
| */ | ||
| public function testDeprecatedCode() | ||
| { | ||
| @trigger_error('This "Foo" method is deprecated.', E_USER_DEPRECATED); | ||
| @trigger_error('The second argument of the "Bar" method is deprecated.', E_USER_DEPRECATED); | ||
| } | ||
| Time-sensitive Tests | ||
| -------------------- | ||
| @@ -340,7 +362,7 @@ its ``bin/simple-phpunit`` command. It has the following features: | ||
| * Does not embed ``symfony/yaml`` nor ``prophecy`` to prevent any conflicts with | ||
| these dependencies; | ||
| * Uses PHPUnit 4.8 when run with PHP <=5.5 and PHPUnit 5.3 when run with PHP >=5.6; | ||
| * Collects and replays skipped tests when the ``SYMFONY_PHPUNIT_SKIPPED_TESTS`` | ||
| env var is defined: the env var should specify a file name that will be used for | ||
| 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 | ||
| $ vendor/bin/simple-phpunit | ||
| .. tip:: | ||
| Set the ``SYMFONY_PHPUNIT_VERSION`` env var to e.g. ``5.5`` to change the | ||
| base version of PHPUnit to ``5.5`` instead of the default ``5.3``. | ||
| .. tip:: | ||
| Set the ``SYMFONY_PHPUNIT_REMOVE`` env var to ``symfony/yaml`` if you need | ||
| ``prophecy`` but not ``symfony/yaml``. | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. What does "if you need" mean? Am I not able to use Prophecy if I don't set this env var to MemberAuthor
| ||
| .. _PHPUnit: https://phpunit.de | ||
| .. _`PHPUnit event listener`: https://phpunit.de/manual/current/en/extending-phpunit.html#extending-phpunit.PHPUnit_Framework_TestListener | ||
| .. _`PHPUnit's assertStringMatchesFormat()`: https://phpunit.de/manual/current/en/appendixes.assertions.html#appendixes.assertions.assertStringMatchesFormat | ||
| .. _`PHP error handler`: http://php.net/manual/en/book.errorfunc.php | ||
| .. _`environment variable`: https://phpunit.de/manual/current/en/appendixes.configuration.html#appendixes.configuration.php-ini-constants-variables | ||
| .. _Packagist: https://packagist.org/packages/symfony/phpunit-bridge | ||