Skip to content

Replace DIC services with mocks in tests #29109

Closed
@Bilge

Description

@Bilge

Description
Since 4.1 we can access private services in tests but we cannot substitute any services with mocks, as may be required by some testing strategies.

Example

self::$container->set('foo', new MockedFoo());

Symfony\Component\DependencyInjection\Exception\InvalidArgumentException : The "foo" service is private, you cannot replace it.
vendor\symfony\dependency-injection\Container.php:163
vendor\symfony\framework-bundle\Test\TestContainer.php:86

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