I've got a solution if you are using this with Behat and API calls. It may be useful in the docs or if it's wrong I'm happy for comments.
I extend the MailerContext to my own like this:
<?php
declare(strict_types=1);
namespace App\Tests\Behat;
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
use Behat\MinkExtension\Context\MinkContext;
use Kocal\SymfonyMailerTesting\MailerLogger;
/**
* @author Daniel West <daniel@silverback.is>
*/
class MailerContext extends \Kocal\SymfonyMailerTesting\Bridge\Behat\MailerContext
{
/**
* @BeforeScenario
*/
public function setMinkContainerLogger(BeforeScenarioScope $scope)
{
/** @var MinkContext $minkContext */
$minkContext = $scope->getEnvironment()->getContext(MinkContext::class);
$this->setMailerLogger($minkContext->getSession()->getDriver()->getClient()->getContainer()->get('test.service_container')->get(MailerLogger::class));
}
}
This way we are getting the logger service being used in the container for the final request when the Mink extension is used.
I've got a solution if you are using this with Behat and API calls. It may be useful in the docs or if it's wrong I'm happy for comments.
I extend the MailerContext to my own like this:
This way we are getting the logger service being used in the container for the final request when the Mink extension is used.