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

Skip to content

SYMFONY_DEPRECATIONS_HELPER has no affect when defined in phpunit.xml.dist. #28726

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

Closed
leevigraham opened this issue Oct 4, 2018 · 8 comments
Closed

Comments

@leevigraham
Copy link
Contributor

Symfony version(s) affected: 4.1.5

Description

Adding <env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled" /> to phpunit.xml.dist has no affect.

How to reproduce

Install the symfony skeleteon

composer create-project symfony/skeleton:4.1.* bug_app
cd bug_app
composer require --dev "symfony/phpunit-bridge:*"
php bin/phpunit

Add <env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled" /> to phpunit.xml.dist as per the configuration docs.

Create a new DeprecatedTest: https://github.com/leevigraham/symonfy-phpunit-bridge/blob/master/tests/DeprecatedTest.php

<?php

namespace App\Tests;

use PHPUnit\Framework\TestCase;

class DeprecatedTest extends TestCase
{
    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);
    }
}

Run php bin/phpunit again. Deprecation notices are shown.

Example Repo: https://github.com/leevigraham/symonfy-phpunit-bridge

Additional context

Screenshot of issue:

image

Running SYMFONY_DEPRECATIONS_HELPER=disabled php bin/phpunit produces expected output:

image

// @nicolas-grekas

@mark-gerarts
Copy link

mark-gerarts commented Oct 4, 2018

I'm guessing this commit is part of the issue. A solution would be to revert this commit and move the functionality to simple-phpunit, where we could do something like

$deprecationsHelper = $getEnvVar('SYMFONY_DEPRECATIONS_HELPER', '999999');
putenv("SYMFONY_DEPRECATIONS_HELPER=$deprecationsHelper");

I'd be happy to open up a PR for this, if I'm thinking in the right direction :)

@nicolas-grekas
Copy link
Member

Duplicate of #28519? See there for some background at least.

@leevigraham
Copy link
Contributor Author

I don't think this is a duplicate of #28519. Any set value is not applied.

@mark-gerarts could be on the right track… I don't see anywhere in code where the phpunit.xml is checked for SYMFONY_DEPRECATIONS_HELPER before setting up the DeprecationErrorHandler in bin/.phpunit/phpunit-6.5/vendor/symfony/phpunit-bridge/bootstrap.php

@leevigraham leevigraham changed the title [symfony/phpunit-bridge] SYMFONY_DEPRECATIONS_HELPER has no affect when defined in phpunit.xml.dist. SYMFONY_DEPRECATIONS_HELPER has no affect when defined in phpunit.xml.dist. Oct 4, 2018
@nicolas-grekas
Copy link
Member

OK, understood. There are two ways to achieve what you'd like:

  • edit the bin/phpunit file and set the value here. That's what I would recommend because it's very early in the bootstrapping process, as it should. This file is yours so you can and should edit it when needed.
  • add force="true" to the phpunit.xml <env> tag.

@curry684
Copy link
Contributor

I found this issue today after being highly surprised that in a colleague's project the disabled value didn't appear to do anything (still got 50+ vendor deprecation notices we don't care about in that project right now). The project was on 4.1.6 and the linked issue was supposedly fixed in 4.1.5, so it's indeed still an issue to some extent. We did notice different behavior between weak and weak_vendors so it's not being ignored completely, just disabled seems to do the same as weak right now.

I don't think the workarounds above are really acceptable for a long term solution.

@leevigraham
Copy link
Contributor Author

edit the bin/phpunit file and set the value here. That's what I would recommend because it's very early in the bootstrapping process, as it should. This file is yours so you can and should edit it when needed.

That's what I ended up doing.

@olia-bn
Copy link

olia-bn commented Oct 17, 2018

We did notice different behavior between weak and weak_vendors so it's not being ignored completely

Memory played a trick on you, there was no difference between weak, weak_vendors and disabled.

@nicolas-grekas
Copy link
Member

fixed at the recipe level in symfony/recipes#481

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

Successfully merging a pull request may close this issue.

6 participants