-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
test.service_container doesn't work with private shared:false services #27488
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
Comments
Hello, this is expected right now: the test container gives access to private services only if they have not been removed or inlined. Since non-shared services are almost always inlineable, you cannot get them. What is the use case of fetching a non-shared service in a test case? |
My non-shared service represents complex's operations on third party API with a session. In our tests, we only want to check if the complex's operations are well craft. |
OK, then I would suggest you access the service via a public alias enabled in the test's config only. The current behavior is correct IMHO. |
|
I changed my mind, see #27528 :) |
…using test.service_container (nicolas-grekas) This PR was merged into the 4.1 branch. Discussion ---------- [FrameworkBundle] give access to non-shared services when using test.service_container | Q | A | ------------- | --- | Branch? | 4.1 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #27488 | License | MIT | Doc PR | - Commits ------- 516ff5a [FrameworkBundle] give access to non-shared services when using test.service_container
Uh oh!
There was an error while loading. Please reload this page.
Symfony version(s) affected: 4.1.x
Description
test.service_container doesn't work with private shared:false services
When we try to load the MyService from the new "test.service_container" we have an exception :
The 'AppMyService' service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead.
Possible Solution
Additional context
The text was updated successfully, but these errors were encountered: