-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[FrameworkBundle] Add KernelTestCase::getContainer() #40366
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At first I thought: Oh no. But I think this makes sense: you'll get a friendly error (instead of a completely different container) and no more "you'll have to boot the kernel first".
Sorry for the complete nitpicking on anything that wasn't PHP code in this review 🙈
Thank you for the review. I've updated the PR according to your suggestions. |
Thank you @Nyholm. |
Thank you for merging. |
There are at least 3 ways to get the container in a test class:
I suggest to add a fourth =)
Basically, in tests you should always use the
test.service_container
. It is hard to remove A and C, but I can deprecate C and add a helper function.This new way will also boot your kernel if it is not already booted.