mirror of
https://github.com/silverstripe/silverstripe-behat-extension
synced 2024-10-22 17:05:32 +02:00
FIX TestMailer instantiation
This commit is contained in:
parent
1786ce115d
commit
ec190a1819
@ -10,7 +10,9 @@ use PHPUnit\Framework\Assert;
|
|||||||
use SilverStripe\BehatExtension\Utility\TestMailer;
|
use SilverStripe\BehatExtension\Utility\TestMailer;
|
||||||
use SilverStripe\Core\Injector\Injector;
|
use SilverStripe\Core\Injector\Injector;
|
||||||
use Symfony\Component\DomCrawler\Crawler;
|
use Symfony\Component\DomCrawler\Crawler;
|
||||||
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
use Symfony\Component\Mailer\MailerInterface;
|
use Symfony\Component\Mailer\MailerInterface;
|
||||||
|
use Symfony\Component\Mailer\Transport\NullTransport;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Context used to define steps related to email sending.
|
* Context used to define steps related to email sending.
|
||||||
@ -48,7 +50,9 @@ class EmailContext implements Context
|
|||||||
{
|
{
|
||||||
// Also set through the 'supportbehat' extension
|
// Also set through the 'supportbehat' extension
|
||||||
// to ensure its available both in CLI execution and the tested browser session
|
// to ensure its available both in CLI execution and the tested browser session
|
||||||
$this->mailer = new TestMailer();
|
$dispatcher = Injector::inst()->get(EventDispatcherInterface::class . '.mailer');
|
||||||
|
$transport = new NullTransport($dispatcher);
|
||||||
|
$this->mailer = new TestMailer($transport, $dispatcher);
|
||||||
Injector::inst()->registerService($this->mailer, MailerInterface::class);
|
Injector::inst()->registerService($this->mailer, MailerInterface::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,8 +2,10 @@
|
|||||||
|
|
||||||
namespace SilverStripe\BehatExtension\Utility;
|
namespace SilverStripe\BehatExtension\Utility;
|
||||||
|
|
||||||
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
use SilverStripe\Dev\TestMailer as BaseTestMailer;
|
use SilverStripe\Dev\TestMailer as BaseTestMailer;
|
||||||
use SilverStripe\TestSession\TestSessionEnvironment;
|
use SilverStripe\TestSession\TestSessionEnvironment;
|
||||||
|
use Symfony\Component\Mailer\Transport\TransportInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Same principle as core TestMailer class,
|
* Same principle as core TestMailer class,
|
||||||
@ -17,8 +19,11 @@ class TestMailer extends BaseTestMailer
|
|||||||
*/
|
*/
|
||||||
protected $testSessionEnvironment;
|
protected $testSessionEnvironment;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct(
|
||||||
{
|
TransportInterface $transport,
|
||||||
|
EventDispatcherInterface $dispatcher
|
||||||
|
) {
|
||||||
|
parent::__construct($transport, $dispatcher);
|
||||||
$this->testSessionEnvironment = TestSessionEnvironment::singleton();
|
$this->testSessionEnvironment = TestSessionEnvironment::singleton();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user