SymfonyTest/symfony-bundle-test

Why was PublicServicePass removed in v2?

Closed this issue ยท 4 comments

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? :)

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

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.

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!