[Bridge\PhpUnit] Add "disabled" mode to SYMFONY_DEPRECATIONS_HELPER#18232
Conversation
74963db to
5ce8438
Compare
|
Status: needs work, for 5.3 support |
That's the only change I'm not really fond of to be honest: if you don't want colors I would expect to set the PHPUnit colors configuration at Otherwise 👍 |
|
@theofidry we don't access to phpunit configuration. PR welcomed if anyone thinks this is of importance. |
Is it because it's something that has been needed until now or there is a reason behind that?
In the example of the color, it doesn't really make sense (at least to me) to set this at the bridge level. But I have no idea of how you access to PHPUnit config so if it's too troublesome then it's understandable. It's just a color setting after all... |
5ce8438 to
89cd063
Compare
|
Status: needs review @theofidry that's it: nobody spent time looking for a way to have tighter phpunit integration, because as you said:
|
89cd063 to
13ed5cf
Compare
|
Fair. This PR will require to update the doc though. |
|
@theofidry would you like opening it please? |
13ed5cf to
49931f4
Compare
|
Tests added |
2e0fa55 to
85852f7
Compare
85852f7 to
8e00abf
Compare
| $mode = preg_match('/^[1-9][0-9]*$/', $mode) ? (int) $mode : 0; | ||
| } | ||
|
|
||
| $mode = function () use ($mode) { |
There was a problem hiding this comment.
reusing the same variable name to store the function makes the code much harder to read
8e00abf to
3a65159
Compare
|
|
||
| putenv('SYMFONY_DEPRECATIONS_HELPER'); | ||
|
|
||
| define('PHPUNIT_COMPOSER_INSTALL', __DIR__.'/../../vendor/autoload.php'); |
There was a problem hiding this comment.
would this work when running tests from the root of the project ?
There was a problem hiding this comment.
no, that's why they are skipped (see line 3-4)
There was a problem hiding this comment.
wouldn't it be better to check for __DIR__.'/../../vendor/autoload.php' instead then ? It would at least be easier to understand
There was a problem hiding this comment.
sure it would, but __DIR__ is not correct/does not work in the SKIPIF section context...
There was a problem hiding this comment.
actually, we cannot use __DIR__ in skipif as it is not replaced before evaluating the code (which is not done from a file anymore).
There was a problem hiding this comment.
btw, would be it possible to support the case of running these tests from the root too ? It would make it easier for contributors to run them.
|
@nicolas-grekas shouldn't most of these tests actually be added in older branches ? |
| --TEST-- | ||
| Test DeprecationErrorHandler in default mode | ||
| --SKIPIF-- | ||
| <?php if (!file_exists('DeprecationErrorHandler.php')) print "skip"; ?> |
There was a problem hiding this comment.
I suggest giving more details about the reason for the test being skipped (for instance skip can only run from a standalone install of the component).
b91ee53 to
d79d731
Compare
Will you backport them before merging this PR though ? It would make the git history cleaner by avoiding to add them twice. |
3cd458d to
5747dc1
Compare
|
Looks good to me. 👍 @nicolas-grekas can you answer my previous question ? |
|
Status: reviewed |
…colas-grekas) This PR was merged into the 2.3 branch. Discussion ---------- [travis] Upgrade phpunit wrapper & hirak/prestissimo | Q | A | ------------- | --- | Branch? | 2.3 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Must be merged after #18232 Commits ------- bf465eb [travis] Upgrade phpunit wrapper & hirak/prestissimo
5747dc1 to
64fe539
Compare
…ATIONS_HELPER (nicolas-grekas) This PR was merged into the 3.1-dev branch. Discussion ---------- [Bridge\PhpUnit] Add "disabled" mode to SYMFONY_DEPRECATIONS_HELPER | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #18222 | License | MIT | Doc PR | - See https://github.com/symfony/symfony/pull/18232/files?w=1 Because we keep adding features to the bridge, so that one could want some features but not the deprecations helper. In weak mode, this PR also disables colors. Fetching the SYMFONY_DEPRECATIONS_HELPER env var is also done lazily to workaround old phpunit versions affected by sebastianbergmann/phpunit#1216 Commits ------- 64fe539 [Bridge\PhpUnit] Add "disabled" mode to SYMFONY_DEPRECATIONS_HELPER
|
No matter what I do I can't disable the depreciations, can you explain clearly how to do that? |
| ); | ||
| $deprecationHandler = function ($type, $msg, $file, $line, $context) use (&$deprecations, $getMode) { | ||
| if (E_USER_DEPRECATED !== $type) { | ||
| if (E_USER_DEPRECATED !== $type || DeprecationErrorHandler::MODE_DISABLED === $mode = $getMode()) { |
See https://github.com/symfony/symfony/pull/18232/files?w=1
Because we keep adding features to the bridge, so that one could want some features but not the deprecations helper.
In weak mode, this PR also disables colors.
Fetching the SYMFONY_DEPRECATIONS_HELPER env var is also done lazily to workaround old phpunit versions affected by sebastianbergmann/phpunit#1216