forked from mautic/mautic
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request mautic#8703 from anton-vlasenko/fix-tokenization-i…
…ssue Fixes issue where support for tokenization was not detected in the MailHelper
- Loading branch information
Showing
6 changed files
with
154 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,8 @@ | |
use Mautic\EmailBundle\Helper\MailHelper; | ||
use Mautic\EmailBundle\MonitoredEmail\Mailbox; | ||
use Mautic\EmailBundle\Swiftmailer\Exception\BatchQueueMaxException; | ||
use Mautic\EmailBundle\Swiftmailer\Spool\DelegatingSpool; | ||
use Mautic\EmailBundle\Swiftmailer\Transport\SpoolTransport; | ||
use Mautic\EmailBundle\Tests\Helper\Transport\BatchTransport; | ||
use Mautic\EmailBundle\Tests\Helper\Transport\BcInterfaceTokenTransport; | ||
use Mautic\EmailBundle\Tests\Helper\Transport\SmtpTransport; | ||
|
@@ -25,6 +27,29 @@ | |
|
||
class MailHelperTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
/** | ||
* @var MauticFactory|\PHPUnit\Framework\MockObject\MockObject | ||
*/ | ||
private $mockFactory; | ||
|
||
/** | ||
* @var SpoolTransport | ||
*/ | ||
private $spoolTransport; | ||
|
||
/** | ||
* @var \Swift_Events_EventDispatcher | ||
*/ | ||
private $swiftEventsDispatcher; | ||
|
||
/** | ||
* @var DelegatingSpool | ||
*/ | ||
private $delegatingSpool; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected $contacts = [ | ||
[ | ||
'id' => 1, | ||
|
@@ -59,6 +84,12 @@ class MailHelperTest extends \PHPUnit\Framework\TestCase | |
protected function setUp() | ||
{ | ||
defined('MAUTIC_ENV') or define('MAUTIC_ENV', 'test'); | ||
|
||
$this->mockFactory = $this->createMock(MauticFactory::class); | ||
$this->swiftEventsDispatcher = $this->createMock(\Swift_Events_EventDispatcher::class); | ||
$this->delegatingSpool = $this->createMock(DelegatingSpool::class); | ||
|
||
$this->spoolTransport = new SpoolTransport($this->swiftEventsDispatcher, $this->delegatingSpool); | ||
} | ||
|
||
/** | ||
|
@@ -702,4 +733,26 @@ public function testArrayOfAddressesAreRemappedIntoEmailToNameKeyValuePair() | |
$mailer->message->getTo() | ||
); | ||
} | ||
|
||
public function testThatTokenizationIsEnabledIfTransportSupportsTokenization() | ||
{ | ||
$swiftMailer = new \Swift_Mailer($this->spoolTransport); | ||
$this->delegatingSpool->expects($this->once()) | ||
->method('isTokenizationEnabled') | ||
->willReturn(true); | ||
|
||
$mailer = new MailHelper($this->mockFactory, $swiftMailer, ['[email protected]' => 'No Body']); | ||
$this->assertTrue($mailer->inTokenizationMode()); | ||
} | ||
|
||
public function testThatTokenizationIsDisabledIfTransportDoesnotSupportTokenization() | ||
{ | ||
$swiftMailer = new \Swift_Mailer($this->spoolTransport); | ||
$this->delegatingSpool->expects($this->once()) | ||
->method('isTokenizationEnabled') | ||
->willReturn(false); | ||
|
||
$mailer = new MailHelper($this->mockFactory, $swiftMailer, ['[email protected]' => 'No Body']); | ||
$this->assertFalse($mailer->inTokenizationMode()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters