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

Skip to content

[PhpunitBridge][HttpKernel]Always display container deprecations in simple phpunit #29519

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

Conversation

l-vo
Copy link
Contributor

@l-vo l-vo commented Dec 8, 2018

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets
License MIT
Doc PR

When the container is not built or not fresh, simple-phpunit may trigger deprecations which occured during container built. If simple-phpunit is launched again, the deprecations are not displayed since the container hasn't be built this time.

Deprecations can make tests fail. So the behavior is currently inconsistent. With the same code base, the tests may pass if the container has been built before and may fail if the container is built during the process.

The suggested fix is to retrieve container compile deprecations from a file created by Symfony. It's the file which is used to display container compile deprecations in Logger data collector.

Some deprecations are generated during cache warmup. Without cache warmup, these deprecations can be triggered from anywhere. For this reason, without cache warmup, we can't memorize them to display them on all test launches. So to keep test launches consistent, it could be a good practice to warmup the cache before.

Note: since phpunit-bridge create a new phpunit project with a phpunit-bridge dependency, the phpunit-bridge version used for the CI tests hasn't the modification of this PR. So the tests fail. Reporting the DeprecationErrorHandler modifications in the created phpunit project allows tests to be successful.

Some very minor bugs has been detected after #29211; it could be a good think to fix the bugs treated by #31478 before merging this PR.

@nicolas-grekas
Copy link
Member

This should be considered as a new feature IMHO.
Since this might be too specific to Symfony functional test cases, would it make sense to move this feature to the KernelTestCase instead of the bridge?

@nicolas-grekas nicolas-grekas added this to the next milestone Dec 8, 2018
@l-vo l-vo changed the title Always display container deprecations in simple phpunit [PhpunitBridge][HttpKernel]Always display container deprecations in simple phpunit Dec 10, 2018
@l-vo l-vo force-pushed the always_display_container_deprecations_in_simple-phpunit branch from 478240a to 7dbde2b Compare December 10, 2018 20:40
@l-vo
Copy link
Contributor Author

l-vo commented Dec 10, 2018

@nicolas-grekas I'm not sure I fully understand. Do you mean that KernelTestCase should catch container compile deprecation and display it (although other deprecations will be displayed by PHPUnit bridge) ?

@nicolas-grekas
Copy link
Member

KernelTestCase could eg open that file and @trigger_error() them - or call the deprecation handler if possible?

@l-vo
Copy link
Contributor Author

l-vo commented Dec 10, 2018

I can't use trigger_error since I would lose original line number information. But maybe I can deal with registered error handler. I'm going to try that, thank you :)

@l-vo
Copy link
Contributor Author

l-vo commented Dec 11, 2018

status: needs work

@l-vo l-vo force-pushed the always_display_container_deprecations_in_simple-phpunit branch from 7dbde2b to 09feeae Compare December 13, 2018 20:58
@l-vo l-vo changed the base branch from 3.4 to master December 13, 2018 20:59
@l-vo l-vo changed the title [PhpunitBridge][HttpKernel]Always display container deprecations in simple phpunit WIP [PhpunitBridge][HttpKernel]Always display container deprecations in simple phpunit Dec 13, 2018
@l-vo l-vo changed the title WIP [PhpunitBridge][HttpKernel]Always display container deprecations in simple phpunit [PhpunitBridge][HttpKernel]Always display container deprecations in simple phpunit Dec 13, 2018
@l-vo
Copy link
Contributor Author

l-vo commented Dec 13, 2018

status: needs work

@l-vo l-vo force-pushed the always_display_container_deprecations_in_simple-phpunit branch 4 times, most recently from 4763a3e to 9197928 Compare December 30, 2018 17:47
@l-vo l-vo force-pushed the always_display_container_deprecations_in_simple-phpunit branch 3 times, most recently from f819427 to 14db14f Compare January 2, 2019 09:57
@fabpot
Copy link
Member

fabpot commented Mar 31, 2019

@l-vo What's the status of your PR?

@l-vo
Copy link
Contributor Author

l-vo commented Mar 31, 2019

@fabpot there is more work than I originally thought. I recently didn't have the time to continue this PR but I didn't forget it :) I'm going back to work on it very soon :)

@fabpot
Copy link
Member

fabpot commented Mar 31, 2019

@l-vo thanks for the feedback.

@l-vo l-vo force-pushed the always_display_container_deprecations_in_simple-phpunit branch 2 times, most recently from 8071a01 to d2749e4 Compare April 28, 2019 15:58
@l-vo l-vo force-pushed the always_display_container_deprecations_in_simple-phpunit branch 2 times, most recently from 268e856 to cadca3a Compare May 16, 2019 15:54
@l-vo l-vo force-pushed the always_display_container_deprecations_in_simple-phpunit branch from cadca3a to bf17514 Compare May 16, 2019 16:03
@l-vo
Copy link
Contributor Author

l-vo commented May 16, 2019

status: needs review

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Jul 8, 2019

Sorry I didn't look close enough before. There is no reason why the phpunit-bridge should know anything about KernelTestCase. Let's find a proper way that would decouple things. There is already some code infrastructure that deals with serialized deprecations passed via messages. Can't we improve this to achieve what is needed here?

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

I think this shouldn't be on phpunit-bridge's side.
Let's have some logic in a base test-case (KernelTestCase?) that triggers those to load the file and trigger the deprecations there.

@l-vo
Copy link
Contributor Author

l-vo commented Aug 3, 2019

@nicolas-grekas I'm not sure to understand. If we put the logic into KernelTestCase (without coupling with phpunit-bridge), we'll lose the logic of the Deprecation class of phpunit-bridge ?

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Aug 3, 2019

You mean: being able to differentiate direct vs indirect deprecations, right? But can't we trigger a serialized message as allowed by the bridge to fix that?

@l-vo
Copy link
Contributor Author

l-vo commented Aug 9, 2019

@nicolas-grekas sorry if I miss something... We can trigger a serialized message, but we must determine in the bridge the message source. It's what is done here, but it's also what introduces the coupling with KernelTestCase.

@nicolas-grekas nicolas-grekas modified the milestones: next, 4.4 Oct 27, 2019
@nicolas-grekas nicolas-grekas modified the milestones: 4.4, next Nov 5, 2019
@nicolas-grekas
Copy link
Member

I'm closing because this would apparently add a lot of complexity for a case that happens to be solvable in other ways. There are other strategies to get the deprecations. It would be nice to achieve the goal here, but not at all costs.
Thanks for giving it a try.

@nicolas-grekas nicolas-grekas modified the milestones: next, 5.1 May 4, 2020
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.

4 participants