Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Bridge\PhpUnit] Add "disabled" mode to SYMFONY_DEPRECATIONS_HELPER #18232

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

Merged
merged 1 commit into from
Mar 23, 2016

Conversation

nicolas-grekas
Copy link
Member

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

@nicolas-grekas nicolas-grekas changed the title [Bridge\PhpUnit] Add "disabled" mode [Bridge\PhpUnit] Add "disabled" mode to SYMFONY_DEPRECATIONS_HELPER Mar 19, 2016
@nicolas-grekas
Copy link
Member Author

Status: needs work, for 5.3 support

@theofidry
Copy link
Contributor

In weak mode, this PR also disables colors.

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 false.

Otherwise 👍

@nicolas-grekas
Copy link
Member Author

@theofidry we don't access to phpunit configuration. PR welcomed if anyone thinks this is of importance.

@theofidry
Copy link
Contributor

we don't access to phpunit configuration

Is it because it's something that has been needed until now or there is a reason behind that?

PR welcomed if anyone thinks this is of importance.

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...

@nicolas-grekas
Copy link
Member Author

Status: needs review
Code updated to work on 5.3

@theofidry that's it: nobody spent time looking for a way to have tighter phpunit integration, because as you said:

It's just a color setting after all...

@theofidry
Copy link
Contributor

Fair.

This PR will require to update the doc though.

@nicolas-grekas
Copy link
Member Author

@theofidry would you like opening it please?

@nicolas-grekas
Copy link
Member Author

Tests added

$mode = preg_match('/^[1-9][0-9]*$/', $mode) ? (int) $mode : 0;
}

$mode = function () use ($mode) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reusing the same variable name to store the function makes the code much harder to read


putenv('SYMFONY_DEPRECATIONS_HELPER');

define('PHPUNIT_COMPOSER_INSTALL', __DIR__.'/../../vendor/autoload.php');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would this work when running tests from the root of the project ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, that's why they are skipped (see line 3-4)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't it be better to check for __DIR__.'/../../vendor/autoload.php' instead then ? It would at least be easier to understand

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure it would, but __DIR__ is not correct/does not work in the SKIPIF section context...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, we cannot use __DIR__ in skipif as it is not replaced before evaluating the code (which is not done from a file anymore).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@stof
Copy link
Member

stof commented Mar 21, 2016

@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"; ?>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

@stof
Copy link
Member

stof commented Mar 21, 2016

right, but it's much simpler for me to make them work on master first, and backport afterwards

Will you backport them before merging this PR though ? It would make the git history cleaner by avoiding to add them twice.

@stof
Copy link
Member

stof commented Mar 23, 2016

Looks good to me. 👍

@nicolas-grekas can you answer my previous question ?

@stof
Copy link
Member

stof commented Mar 23, 2016

Status: reviewed

nicolas-grekas added a commit that referenced this pull request Mar 23, 2016
…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
@nicolas-grekas nicolas-grekas merged commit 64fe539 into symfony:master Mar 23, 2016
nicolas-grekas added a commit that referenced this pull request Mar 23, 2016
…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
@nicolas-grekas nicolas-grekas deleted the phpunit-wa branch March 23, 2016 13:50
@fabpot fabpot mentioned this pull request May 13, 2016
@joeyhub
Copy link

joeyhub commented Mar 19, 2019

No matter what I do I can't disable the depreciations, can you explain clearly how to do that?

@@ -67,11 +68,10 @@ public static function register($mode = 0)
'other' => array(),
);
$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()) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is $mode used?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants