-
Notifications
You must be signed in to change notification settings - Fork 36
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 #66 from Silarn/develop
Magento 2.2.4: Ensure Message objects are the same on both TransportB…
- Loading branch information
Showing
13 changed files
with
139 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
namespace Ebizmarts\Mandrill\Model; | ||
|
||
use Magento\Framework\Mail\Template\TransportBuilder; | ||
use Magento\Framework\Mail\Template\TransportBuilderByStore; | ||
use Magento\Sales\Model\Order\Email\Container\IdentityInterface; | ||
use Magento\Sales\Model\Order\Email\Container\Template; | ||
use Magento\Framework\Mail\MessageInterface; | ||
use Magento\Framework\ObjectManagerInterface; | ||
|
||
class SenderBuilder extends \Magento\Sales\Model\Order\Email\SenderBuilder | ||
{ | ||
/** | ||
* SenderBuilder constructor. | ||
* | ||
* @param Template $templateContainer | ||
* @param IdentityInterface $identityContainer | ||
* @param ObjectManagerInterface $objectManager | ||
*/ | ||
public function __construct( | ||
Template $templateContainer, | ||
IdentityInterface $identityContainer, | ||
ObjectManagerInterface $objectManager | ||
) { | ||
/** @var MessageInterface $message */ | ||
$message = $objectManager->create(MessageInterface::class); | ||
/** @var TransportBuilder $transportBuilder */ | ||
$transportBuilder = $objectManager->create( | ||
TransportBuilder::class, | ||
["message" => $message] | ||
); | ||
/** @var TransportBuilderByStore $transportBuilderByStore */ | ||
$transportBuilderByStore = $objectManager->create( | ||
TransportBuilderByStore::class, | ||
["message" => $message] | ||
); | ||
parent::__construct($templateContainer, $identityContainer, $transportBuilder, $transportBuilderByStore); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
|
||
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; | ||
|
||
class UnsubscribeTest extends \PHPUnit_Framework_TestCase | ||
class UnsubscribeTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
|
||
const EMAIL = "[email protected]"; | ||
|
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
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 |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
/** | ||
* Ebizmarts_Mandrill Magento JS component | ||
* | ||
* @category Ebizmarts | ||
* @package Ebizmarts_Mandrill | ||
* @author Ebizmarts Team <[email protected]> | ||
* @copyright Ebizmarts (http://ebizmarts.com) | ||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
*/ | ||
|
||
|
||
namespace Ebizmarts\Mandrill\Test\Unit\Model; | ||
|
||
use Ebizmarts\Mandrill\Model\SenderBuilder; | ||
use Magento\Framework\Mail\Template\TransportBuilder; | ||
use Magento\Framework\Mail\Template\TransportBuilderByStore; | ||
use \Magento\Framework\ObjectManagerInterface; | ||
use Magento\Sales\Model\Order\Email\Container\IdentityInterface; | ||
use Magento\Sales\Model\Order\Email\Container\Template; | ||
use Magento\Framework\Mail\MessageInterface; | ||
|
||
class SenderBuilderTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
public function testSameMessage() | ||
{ | ||
// Core mock class | ||
$builder = $this->getMockBuilder(SenderBuilder::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
// Mock parameters | ||
$templateMock = $this->getMockBuilder(Template::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
$identityMock = $this->getMockBuilder(IdentityInterface::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
$objectManagerMock = $this->getMockBuilder(ObjectManagerInterface::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
// Message object to get and test against | ||
$messageMock = $this->getMockBuilder(MessageInterface::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
// Transport builders created by ObjectManager | ||
$transportBuilderMock = $this->getMockBuilder(TransportBuilder::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
$transportBuilderSenderMock = $this->getMockBuilder(TransportBuilderByStore::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
// Make sure the ObjectManager returns our mock Message | ||
$objectManagerMock->expects($this->at(0)) | ||
->method('create') | ||
->will($this->returnValue($messageMock)); | ||
|
||
// Tests that both TransportBuilder models are created with the same Message object | ||
$objectManagerMock->expects($this->at(1)) | ||
->method('create') | ||
->with($this->equalTo(TransportBuilder::class), $this->contains($messageMock)) | ||
->will($this->returnValue($transportBuilderMock)); | ||
$objectManagerMock->expects($this->at(2)) | ||
->method('create') | ||
->with($this->equalTo(TransportBuilderByStore::class), $this->contains($messageMock)) | ||
->will($this->returnValue($transportBuilderSenderMock)); | ||
|
||
// Create a reflection of the SenderBuilder constructor to invoke on our mock Builder | ||
$reflection = new \ReflectionClass(SenderBuilder::class); | ||
$constructor = $reflection->getConstructor(); | ||
|
||
// Invoke the mock Builder with a reflection of the constructor and our mock objects | ||
$constructor->invoke($builder, $templateMock, $identityMock, $objectManagerMock); | ||
} | ||
} |
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