Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #13398 [PhpUnit] new PhpUnit bridge (nicolas-grekas)
This PR was merged into the 2.7 branch. Discussion ---------- [PhpUnit] new PhpUnit bridge | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #13644 | License | MIT | Doc PR | - From the proposed README: PHPUnit Bridge ============== Provides utilities for PHPUnit, especially user deprecation notices management. It comes with the following features: * disable the garbage collector; * auto-register `class_exists` to load Doctrine annotations; * print a user deprecation notices summary at the end of the test suite. Handling user deprecation notices is sensitive to the SYMFONY_DEPRECATIONS_HELPER environment variable. This env var configures 3 behaviors depending on its value: * when set to `strict`, all but legacy-tagged deprecation notices will make tests fail. This is the recommended mode for best forward compatibility. * `weak` on the contrary will make tests ignore all deprecation notices. This is the recommended mode for legacy projects that must use deprecated interfaces for backward compatibility reasons. * any other value will respect the current error reporting level. All three modes will display a summary of deprecation notices at the end of the test suite, split in two groups: * **Legacy** deprecation notices denote tests that explicitly test some legacy interfaces. In all 3 modes, deprecation notices triggered in a legacy-tagged test do never make a test fail. There are four ways to mark a test as legacy: - make its class start with the `Legacy` prefix; - make its method start with `testLegacy`; - make its data provider start with `provideLegacy` or `getLegacy`; - add the `@group legacy` annotation to its class or method. * **Remaining/Other** deprecation notices are all other (non-legacy) notices, grouped by message, test class and method. Usage ----- Add this bridge to the `require-dev` section of your composer.json file (not in `require`) with e.g. `composer require --dev "symfony/phpunit-bridge"`. When running `phpunit`, you will see a summary of deprecation notices at the end of the test suite. Deprecation notices in the **Remaining/Other** section need some thought. You have to decide either to: * update your code to not use deprecated interfaces anymore, thus gaining better forward compatibility; * or move them to the **Legacy** section (by using one of the above way). After reviewing them, you should silence deprecations in the **Legacy** section if you think they are triggered by tests dedicated to testing deprecated interfaces. To do so, add the following line at the beginning of your legacy test case or in the `setUp()` method of your legacy test class: `$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);` Last but not least, you should then configure your C.I. to the reporting mode that is appropriated to your project by setting SYMFONY_DEPRECATIONS_HELPER to `strict`, `weak` or empty. It is recommended to start with `weak` mode, upgrade your code as described above, then when the *Remaining/Other* sections are empty, move to `strict` to keep forward compatibility on the long run. Commits ------- acac734 [PhpUnitBridge] new bridge for testing with PHPUnit
- Loading branch information
Showing
100 changed files
with
372 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
vendor/ | ||
composer.lock | ||
phpunit.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Copyright (c) 2014-2015 Fabien Potencier | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is furnished | ||
to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
PHPUnit Bridge | ||
============== | ||
|
||
Provides utilities for PHPUnit, especially user deprecation notices management. | ||
|
||
It comes with the following features: | ||
|
||
* disable the garbage collector; | ||
* auto-register `class_exists` to load Doctrine annotations; | ||
* print a user deprecation notices summary at the end of the test suite. | ||
|
||
Handling user deprecation notices is sensitive to the SYMFONY_DEPRECATIONS_HELPER | ||
environment variable. This env var configures 3 behaviors depending on its value: | ||
|
||
* when set to `strict`, all but legacy-tagged deprecation notices will make tests | ||
fail. This is the recommended mode for best forward compatibility. | ||
* `weak` on the contrary will make tests ignore all deprecation notices. | ||
This is the recommended mode for legacy projects that must use deprecated | ||
interfaces for backward compatibility reasons. | ||
* any other value will respect the current error reporting level. | ||
|
||
All three modes will display a summary of deprecation notices at the end of the | ||
test suite, split in two groups: | ||
|
||
* **Legacy** deprecation notices denote tests that explicitly test some legacy | ||
interfaces. In all 3 modes, deprecation notices triggered in a legacy-tagged | ||
test do never make a test fail. There are four ways to mark a test as legacy: | ||
- make its class start with the `Legacy` prefix; | ||
- make its method start with `testLegacy`; | ||
- make its data provider start with `provideLegacy` or `getLegacy`; | ||
- add the `@group legacy` annotation to its class or method. | ||
* **Remaining/Other** deprecation notices are all other (non-legacy) | ||
notices, grouped by message, test class and method. | ||
|
||
Usage | ||
----- | ||
|
||
Add this bridge to the `require-dev` section of your composer.json file | ||
(not in `require`) with e.g. | ||
`composer require --dev "symfony/phpunit-bridge"`. | ||
|
||
When running `phpunit`, you will see a summary of deprecation notices at the end | ||
of the test suite. | ||
|
||
Deprecation notices in the **Remaining/Other** section need some thought. | ||
You have to decide either to: | ||
|
||
* update your code to not use deprecated interfaces anymore, thus gaining better | ||
forward compatibility; | ||
* or move them to the **Legacy** section (by using one of the above way). | ||
|
||
After reviewing them, you should silence deprecations in the **Legacy** section | ||
if you think they are triggered by tests dedicated to testing deprecated | ||
interfaces. To do so, add the following line at the beginning of your legacy | ||
test case or in the `setUp()` method of your legacy test class: | ||
`$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);` | ||
|
||
Last but not least, you should then configure your C.I. to the reporting mode | ||
that is appropriated to your project by setting SYMFONY_DEPRECATIONS_HELPER to | ||
`strict`, `weak` or empty. It is recommended to start with `weak` mode, upgrade | ||
your code as described above, then when the *Remaining/Other* sections are empty, | ||
move to `strict` to keep forward compatibility on the long run. |
Oops, something went wrong.