-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[FrameworkBundle] Allow fetching private services from test clients #26499
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
*/ | ||
public function compile() | ||
{ | ||
return $this->publicContainer->isCompiled(); |
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.
Typo? $this->publicContainer->compile();
Looks promising! The only issue I see is that it currently requires the Edit: I guess in such scenario we can still do |
In my experience, this would be useful for any |
b944061
to
8e1ef8f
Compare
OK, what about the new patch? |
Better :) |
626b6ad
to
d5c7c60
Compare
PR ready. Unused private services are still removed. This is a requirement because not all private services are valid. Since they are removed, this is not an issue but a feature. Keeping a reference to all private services would be a BC break (as experienced on the test suite before handling this.) |
d5c7c60
to
196e5c3
Compare
196e5c3
to
a840809
Compare
… test clients (nicolas-grekas) This PR was merged into the 4.1-dev branch. Discussion ---------- [FrameworkBundle] Allow fetching private services from test clients | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #25814 | License | MIT | Doc PR | - With this PR, `$client->getContainer()` returns a special container that gives access to private services as if they were public. Tests derived from `WebTestCase` and `KernelTestCase` can access this special container by using the new `static::$container` property. Commits ------- a840809 [FrameworkBundle] Allow fetching private services from test clients
@nicolas-grekas It will be available in 3.4 version? |
that's a new feature, so for 4.1 |
So, actual code that's being tested will still use regular container that cannot access private services, right? |
@umpirski right. |
Since symfony/symfony#26499 will not be part of Symfony 3.4 regrettably.
With this PR,
$client->getContainer()
returns a special container that gives access to private services as if they were public.Tests derived from
WebTestCase
andKernelTestCase
can access this special container by using the newstatic::$container
property.