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

Injecting services and using mocks in tests after deprecation #23772

Copy link
Copy link
Closed
@scott-r-lindsey

Description

@scott-r-lindsey
Issue body actions
Q A
Bug report? no
Feature request? yes
BC Break report? no
RFC? no
Symfony version 3.2.0

I open this issue, more or less a dupe of issue 23311 hopefully create some more discussion around the deprecation of Container::set() for non-synthetic services (#19192). I can't imagine a use case for Container::set() outside of testing, but in the context of testing it is very, very helpful.

My use case is testing a large application which interacts with a number of APIs via Guzzle clients (configured as services) provided by 8p/GuzzleBundle.

My test suite replaces the various Guzzle services with Guzzle MocksHandlers immediately after booting the Kernel. This lets me boot and exercise the entire application, validate outgoing requests, and creates hard errors when unexpected requests are attempted.

It seems that I'm a year late to object to this feature being removed, but for those of us that we using it it was invaluable. Is there an objection to @emil-nasso's proposed solution? Alternate configuration by itself doesn't get us very far.

I can't think of a solution to this that is close to as clean as the old way of doing it, so please correct me if I'm missing something.

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.