Skip to content
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

Simple phpunit throws Doctrine deprecated notices even with using Symfony_deprecations_helper=disabled env var #28028

Closed
ChangePlaces opened this issue Jul 22, 2018 · 5 comments

Comments

@ChangePlaces
Copy link

ChangePlaces commented Jul 22, 2018

Symfony version(s) affected: 4.1.1

Description
Unit test run throws deprecation notices. I've tried to read a lot about the issue and it seems to centre around Symfony catching and displaying all deprecation notices, even those that have been silenced - the issue I'm assuming the issue is around Doctrine being split into separate components for v3.

I've read using <env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled"/> should silence them which I have in a phpunit.xml except, the handler is still registered. Even though this key is here, during the phpunit bootstrap, false is returned for any getenv call thus forcing the registration of the deprecation handler.

Deprecated notices I received were 2x: Doctrine\Common\ClassLoader is deprecated. and 1x: Enabling the "sensio_framework_extra.router.annotations" configuration is deprecated since version 5.2. Set it to false and use the "Symfony\Component\Routing\Annotation\Route" annotation from Symfony itself.

How to reproduce
Create phpunit.xml and put inside <env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled"/>, with (what appears to be a basic test suite). Still trying to ascertain exactly why certain tests are causing these deprecation notices to appear.

@nicolas-grekas
Copy link
Member

I'd suggest to set the env vars in bin/phpunit instead, it's already setting a few env vars for configuring the bridge, see
https://github.com/symfony/recipes/blob/master/symfony/phpunit-bridge/4.1/bin/phpunit

@nicolas-grekas
Copy link
Member

Re-read the code, I confirm: configuring the bridge with phpunit.xml is too late, setting SYMFONY_DEPRECATIONS_HELPER with putenv as in https://github.com/symfony/recipes/blob/master/symfony/phpunit-bridge/4.1/bin/phpunit is the way to go.
Closing as there is no bug to keep track of. Cheers.

@ChangePlaces
Copy link
Author

This IS a bug as there is no clear documentation detailing this. Something on the testing page should be added regarding using putenv then.

@nicolas-grekas
Copy link
Member

Related (since it can help "documenting"): symfony/recipes#442
About doc, see https://symfony.com/doc/current/components/phpunit_bridge.html#making-tests-fail
If you think the doc should be improved, please open a doc issue (this repo is for code-related bugs only.)

@ChangePlaces
Copy link
Author

As you're making the change I think you should be opening the issue in docs / making a docs PR as you will know best

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

No branches or pull requests

4 participants