Skip to content
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

Why was PublicServicePass removed in v2? #72

Closed
loevgaard opened this issue Oct 11, 2022 · 4 comments · May be fixed by #76
Closed

Why was PublicServicePass removed in v2? #72

loevgaard opened this issue Oct 11, 2022 · 4 comments · May be fixed by #76
Labels

Comments

@loevgaard
Copy link
Contributor

Thanks for this great package 🎉

Why was https://github.com/SymfonyTest/symfony-bundle-test/blob/1.x/src/CompilerPass/PublicServicePass.php removed in v2? If I want to test services that are only used by users of the bundle they are removed by default in Symfony and hence I cannot test them using this package. If I mark them public with the old PublicServicePass then I can.

Can you elaborate on this? Am I missing something? :)

@chapterjason
Copy link
Contributor

Hey @loevgaard, it was removed in #48 as Symfony provides the test.service_container which gives you access to private services.

https://symfony.com/doc/current/testing.html#retrieving-services-in-the-test

@loevgaard
Copy link
Contributor Author

@chapterjason
Copy link
Contributor

Yes, that is right.

If you need to test private services that have been removed (those who are not used by any other services), you need to declare those private services as public in the config/services_test.yaml file.

IMO It is better to explicitly set only the neccessary services public in a separate file and load it with addTestConfig.

@loevgaard
Copy link
Contributor Author

That may be right. I find it easier to do with the compiler pass, but yes your way is more explicit. Thanks for your quick response!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants