-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[PhpUnit] new PhpUnit bridge #13398
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PhpUnit] new PhpUnit bridge #13398
Conversation
} | ||
], | ||
"require": { | ||
"php": ">=5.3.3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not 5.3.9 to allow standalone reuse on older projects
e9d43d7
to
4456d31
Compare
AnnotationRegistry::registerLoader(array($loader, 'loadClass')); | ||
private static function hasColorSupport() | ||
{ | ||
if (DIRECTORY_SEPARATOR == '\\') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be ===
4456d31
to
f0458c2
Compare
}, | ||
"autoload": { | ||
"psr-0": { "Symfony\\Component\\Testing\\": "" }, | ||
"files": [ "bootstrap.php" ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems wrong to me. You want the bootstrap.php file to be loaded only when running the testsuite of your project, not when running your project locally (and you don't want to need to reinstall the project without dev requirements all the time during development
8e58ddf
to
25b69fd
Compare
} | ||
], | ||
"require": { | ||
"php": ">=5.3.3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
">=5.3.9" is requirement since 6dc8979
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, I overlooked the original comment on the "outdated diff", where it is sated that it is intentionally, so my last comment can be ignored
25b69fd
to
1f79a32
Compare
}, | ||
"autoload-dev": { | ||
"files": [ "Resources/bootstrap/symfony.php" ] | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are aware that this won't be used when the package is required in another package? Dev config will only be tracked when the package is the root package.
I don't like it's name, as it doesn't really provide much testing help apart from easing the transition between 2.x and 3.x. Maybe we're going to need more utilities for this transition, what about renaming this component to have all this utilities? |
…reak the build if we treat deprecated as an error
Talking a bit with some others, I'm going to move this to |
2322d42
to
1d35ce6
Compare
|
||
if (class_exists('Doctrine\Common\Annotations\AnnotationRegistry')) { | ||
AnnotationRegistry::registerLoader('class_exists'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should add MongoDB annotations too.
http://symfony.com/doc/current/bundles/DoctrineMongoDBBundle/index.html#register-the-annotations-and-the-bundle
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed. The MongoDB annotations are autoloadable, so this is enough to register them (registering class_exists in the AnnotationRegistry is enough as long as all your autoloaders are handling properly the case of a non-existant class, i.e. not breaking class_exists
)
c636b94
to
5345d98
Compare
18aced3
to
533a9b3
Compare
README updated |
"psr-0": { "Symfony\\Bridge\\PhpUnit\\": "" } | ||
}, | ||
"target-dir": "Symfony/Bridge/PhpUnit", | ||
"minimum-stability": "dev", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems a bit odd, as it has no dependencies
20c61f3
to
5124a11
Compare
PHPUnit Bridge | ||
============== | ||
|
||
Utilities for PHPUnit, especially user deprecation notices management. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure that it was not what I proposed. We have a uniform way to describe each component in one sentence. So, it should be Provides utilities ...
5124a11
to
6b95d85
Compare
|
||
Provides utilities for PHPUnit, especially user deprecation notices management. | ||
|
||
It comesa with the following features: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo comes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
6b95d85
to
1940dc9
Compare
1940dc9
to
acac734
Compare
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Nicolas Grekas", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what approach we are following here. But Form and PropertyAccess Component for example created by Bernhard have Fabien as author. So it's kinda inconsistent. I guess we should either only add the Symfony Community, or maybe all Mergers as author. This way it also helps as reference to find a contact person.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a matter of fact, I'm the author of this component... @fabpot is the copyright owner mentionned in the LICENSE file, but I wrote the code. This is just plain descriptive truth. If someone else wrote some other component (or a significant non-trivial part of it), he/she should also be mentionned as author IMHO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fine because he already had things like this merged https://github.com/symfony/symfony/blob/2.7/src/Symfony/Component/VarDumper/composer.json#L10 and it just makes sense. If the other components were attributed to @fabpot well that is because it was ok with their authors perhaps.
Please note that I modified the .travis file to ignore tests in the legacy group. There are no tests tagged |
|
||
* 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test suite output?
Thank you @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
From the proposed README:
PHPUnit Bridge
Provides utilities for PHPUnit, especially user deprecation notices management.
It comes with the following features:
class_exists
to load Doctrine annotations;Handling user deprecation notices is sensitive to the SYMFONY_DEPRECATIONS_HELPER
environment variable. This env var configures 3 behaviors depending on its value:
strict
, all but legacy-tagged deprecation notices will make testsfail. 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.
All three modes will display a summary of deprecation notices at the end of the
test suite, split in two groups:
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:
Legacy
prefix;testLegacy
;provideLegacy
orgetLegacy
;@group legacy
annotation to its class or method.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 endof the test suite.
Deprecation notices in the Remaining/Other section need some thought.
You have to decide either to:
forward compatibility;
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 withweak
mode, upgradeyour code as described above, then when the Remaining/Other sections are empty,
move to
strict
to keep forward compatibility on the long run.