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

Cannot get service in tests #36147

Copy link
Copy link
Closed
Closed
Copy link
@enumag

Description

@enumag
Issue body actions

Symfony version: 4.4.5

I'm starting a new project (using SF 4.4 because it's LTS) and in my tests I'd like to use the new feature that enables getting services easily in tests.

However even when doing everything as described on a completely fresh project without any hacks I'm still getting this error:

Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: The "MyServiceClass" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead.

The exception stack trace contains vendor/symfony/framework-bundle/Test/TestContainer.php:106 which proves that the "special container" as described in the post is indeed used. But I still can't get the service.

What else do I need to enable to use this feature?

Metadata

Metadata

Assignees

No one assigned

    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.