Container - gricob/functional-test-bundle GitHub Wiki

Using the container

$service = $this->getContainer()->get('desired.service');
$parameter = $this->getContainer()->getParameter('desired.parameter');

Getting private services

$service = $this->getTestContainer()->get('desired.private.service);

Prevent removing unused services

Symfony removes private services that are not in use. If you try to get any of those services, you will get the following error:

The "unused_private_service" service or alias has been removed or inlined when the container was compiled.

To prevent the service to be removed, add it to the unused_services array in configuration:

functional_test:
    unused_definitions:
        - 'unused_private_service'