You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use the PSR logger in my command and I would like to be able to mock it so that I can monitor its outputs. However, when I have this:
class CommandTest extends KernelTestCase
{
private readonly LoggerInterface | ObjectProphecy $logger;
private readonly Application $application;
public function setUp(): void
{
parent::setUp();
$this->application = new Application(self::bootKernel());
$container = static::getContainer();
$logger = $this->prophesize(LoggerInterface::class);
$container->set(LoggerInterface::class, $logger->reveal());
}
It tells me that:
Symfony\Component\DependencyInjection\Exception\InvalidArgumentException : The "Psr\Log\LoggerInterface" service is already initialized, you cannot replace it..
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I use the PSR logger in my command and I would like to be able to mock it so that I can monitor its outputs. However, when I have this:
It tells me that:
Symfony\Component\DependencyInjection\Exception\InvalidArgumentException : The "Psr\Log\LoggerInterface" service is already initialized, you cannot replace it.
.How can I replace the dependency in this case?
Beta Was this translation helpful? Give feedback.
All reactions