8000 [PHPUnit] SYMFONY_DEPRECATIONS_HELPER var is in the wrong place (.env.test) · Issue #30047 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[PHPUnit] SYMFONY_DEPRECATIONS_HELPER var is in the wrong place (.env.test) #30047

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
proArtex opened this issue Jan 30, 2019 · 6 comments
Closed

Comments

@proArtex
Copy link
proArtex commented Jan 30, 2019

Symfony version(s) affected:

  • symfony/test-pack: 1.0.5
  • symfony/phpunit-bridge: 4.2.2

Description
Phpunit recipe contains SYMFONY_DEPRECATIONS_HELPER env var inside .env.test file. But it doesn't work here.

How to reproduce

  • write a WebTestCase that triggers deprecation warning
  • set SYMFONY_DEPRECATIONS_HELPER=weak inside .env.test (or .env.test.local)
  • run rm -rf var/cache
  • run bin/phpunit
    Then you will see the "Remaining deprecation notices ..." message and exit code 1

Possible Solution
Put SYMFONY_DEPRECATIONS_HELPER variable inside phpunit.xml.dist file
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak" />

@nicolas-grekas
Copy link
Member

Reading from SYMFONY_DEPRECATIONS_HELPER should be lazy, so it should work. Maybe a bug to find and kill?

@ossinkine
Copy link
Contributor

DeprecationErrorHandler::getMode() is called first time when error include(/app/.env.local.php): failed to open stream: No such file or directory is thrown in bootstrap.php. Mode is set to 0 and cached. After that .env.test is loaded but it does not affect the mode anymore.

@nicolas-grekas What is the best way to fix this?

@nicolas-grekas
Copy link
Member

I think we should try fixing this in the bridge if possible, by not resolving the mode until a deprecation is actually triggered. Doable?

@ossinkine
Copy link
Contributor

@nicolas-grekas Yes, I'll create a PR.
Which branch should be target for this fix?

@nicolas-grekas
Copy link
Member

3.4!

nicolas-grekas added a commit that referenced this issue Feb 16, 2019
…eprecation is triggered (ossinkine)

This PR was merged into the 3.4 branch.

Discussion
----------

Don't resolve the Deprecation error handler mode until a deprecation is triggered

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #30047
| License       | MIT

<!--
Write a short README entry for your feature/bugfix here (replace this comment block.)
This will help people understand your PR and can be used as a start of the Doc PR.
Additionally:
 - Bug fixes must be submitted against the lowest branch where they apply
   (lowest branches are regularly merged to upper ones so they get the fixes too).
 - Features and deprecations must be submitted against the master branch.
-->
If an error happens before `.env.test` is loaded the mode is set to 0 and cached so SYMFONY_DEPRECATIONS_HELPER is not read from `.env.test`.

Commits
-------

1090b8c Don't resolve the Deprecation error handler mode until a deprecation is triggered
@zacharra
Copy link
zacharra commented Mar 6, 2019

@ossinkine @nicolas-grekas Hello there, sorry for writing in this closed issue for which a fix exists, but I see that although we have a merged fix for this, which is referenced in the new 4.2.4 release notes, it did in fact not land in the 4.2 branch at all. The issue still exists with the PHPUnit-Bridge in v4.2.4 . It seems the merge from the 3.4 branch to the 4.2 one wasn't done correctly or something, though I'm not sure about this. I can see at least that the fix in the DeprecationErrorHandler.php file is in the master branch (though looking slightly different there), so I wasn't sure if I should open a new issue or not.
I tried to get opinions on that matter in your Developer's Slack, but unfortunately no one answered there^^.

nicolas-grekas added a commit that referenced this issue Mar 8, 2019
…eprecation is triggered (Emmanuel BORGES)

This PR was squashed before being merged into the 4.2 branch (closes #30490).

Discussion
----------

Don't resolve the Deprecation error handler mode until a deprecation is triggered

| Q             | A
| ------------- | ---
| Branch?       | 4.2
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #30047
| License       | MIT

Don't resolve the Deprecation error handler mode until a deprecation is triggered

Commits
-------

f3a5b74 Don't resolve the Deprecation error handler mode until a deprecation is triggered
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

5 participants
0