Closed
Description
In my integration tests I want to replace a service by a fake implementation. For example I want to temporarily replace the event_dispatcher
by a mock that will store all triggered events:
$container->set('event_dispatcher', $fakeDispatcher);
The problem is that event_dispatcher
is an alias, and Container::get()
first resolves aliases before trying to find the entry.
That makes Container::set()
silently useless when setting an entry that is an alias.
IMO this is a bug, and I see 2 solutions (by order of preference), feel free to suggest alternatives:
set()
should erase any existing alias because it should just workset()
should throw an exception if setting an alias
I can implement the solution if one is chosen.