Skip to content

Navigation Menu

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

What is the idiomatic way to inject a private third-party service into a WebTestCase in 3.4/4.0? #24543

Copy link
Copy link
Closed
@manuelkiessling

Description

@manuelkiessling
Issue body actions
Q A
Bug report? no
Feature request? no
BC Break report? no
RFC? no
Symfony version 3.4.0-DEV

Up until 3.3, I would often make use of container services from within my WebTestCases, like this:

$um = $container->get('fos_user.user_manager');
$user = $um->findUserByEmail('johndoe@example.com');

However, fos_user.user_manager is a private service, and 3.4 deprecates retrieving those through the container.

The easy way out is to alias the service to make it public in services.yml, like this:

fos_user.user_manager.public:
    alias: fos_user.user_manager
    public: true

but that doesn't feel like the right thing to do.

I tried to get setter injection working, but this seems to be limited to classes within the container, and doesn't seem to work for WebTestCase classes.

Is there a general/idiomatic approach to access private services from within WebTestCase classes?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No 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.