mirror of
https://github.com/silverstripe/silverstripe-behat-extension
synced 2024-10-22 17:05:32 +02:00
Merge pull request #230 from creative-commoners/pulls/5/mailer
FIX TestMailer instantiation
This commit is contained in:
commit
cd724e539d
@ -10,7 +10,9 @@ use PHPUnit\Framework\Assert;
|
||||
use SilverStripe\BehatExtension\Utility\TestMailer;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use Symfony\Component\DomCrawler\Crawler;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\Mailer\MailerInterface;
|
||||
use Symfony\Component\Mailer\Transport\NullTransport;
|
||||
|
||||
/**
|
||||
* Context used to define steps related to email sending.
|
||||
@ -48,7 +50,9 @@ class EmailContext implements Context
|
||||
{
|
||||
// Also set through the 'supportbehat' extension
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
@ -2,8 +2,10 @@
|
||||
|
||||
namespace SilverStripe\BehatExtension\Utility;
|
||||
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use SilverStripe\Dev\TestMailer as BaseTestMailer;
|
||||
use SilverStripe\TestSession\TestSessionEnvironment;
|
||||
use Symfony\Component\Mailer\Transport\TransportInterface;
|
||||
|
||||
/**
|
||||
* Same principle as core TestMailer class,
|
||||
@ -17,8 +19,11 @@ class TestMailer extends BaseTestMailer
|
||||
*/
|
||||
protected $testSessionEnvironment;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
public function __construct(
|
||||
TransportInterface $transport,
|
||||
EventDispatcherInterface $dispatcher
|
||||
) {
|
||||
parent::__construct($transport, $dispatcher);
|
||||
$this->testSessionEnvironment = TestSessionEnvironment::singleton();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user