symfony-bundle-test icon indicating copy to clipboard operation
symfony-bundle-test copied to clipboard

Add instructions about testing unused private services

Open loevgaard opened this issue 2 years ago • 3 comments

Fixes https://github.com/SymfonyTest/symfony-bundle-test/issues/72

loevgaard avatar Feb 21 '23 08:02 loevgaard

I don't think this is required anymore?

chapterjason avatar Oct 28 '23 14:10 chapterjason

I think it is, @chapterjason. Why do you think it isn't? :)

loevgaard avatar Nov 03 '23 15:11 loevgaard

I don't see any value here as you can easily make them available by make them public in a test config like described in the symfony documentation

The container from static::getContainer() is actually a special test container. It gives you access to both the public services and the non-removed private services.

Yes I know you mean removed ones:

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.

You can do this in bundle test by simply loading a test config with the method addTestConfig from the TestKernel.

Edit: We actually could add a bit documentation how to do this.

chapterjason avatar Nov 03 '23 17:11 chapterjason