Closed
Description
Question:
What if you do container->get() some services in tests.
Answer:
The proper solution would be to create a public alias for the service you want to test in the test environment only:
# app/config/config_test.yml
services:
test_alias.AppBundle\Service\MyService:
alias: 'AppBundle\Service\MyService'
public: true # require on SF4, where everything is private by default
Then, you would actually fetch test_alias.AppBundle\Service\MyService
out of the container in your unit test. It's a nice idea too: you only need to expose your service as public in the test environment.