Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Document how to "integration" test private services #8097

Copy link
Copy link
Closed
@weaverryan

Description

@weaverryan
Issue body actions

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.