14 class MailTest extends \PHPUnit\Framework\TestCase
30 private $transportBuilderMock;
35 private $inlineTranslationMock;
40 private $storeManagerMock;
49 $this->configMock = $this->getMockBuilder(ConfigInterface::class)->getMockForAbstractClass();
50 $this->urlMock = $this->createMock(\
Magento\Framework\UrlInterface::class);
51 $this->transportBuilderMock = $this->getMockBuilder(
52 \
Magento\Framework\
Mail\Template\TransportBuilder::class
53 )->disableOriginalConstructor(
55 $this->inlineTranslationMock = $this->getMockBuilder(
57 )->disableOriginalConstructor(
60 $this->storeManagerMock = $this->createMock(StoreManagerInterface::class);
62 $this->mail =
new Mail(
64 $this->transportBuilderMock,
65 $this->inlineTranslationMock,
66 $this->storeManagerMock
73 $templateVars = [
'comment' =>
'Comment'];
75 $transport = $this->createMock(\
Magento\Framework\
Mail\TransportInterface::class);
77 $store = $this->createMock(StoreInterface::class);
78 $store->expects($this->once())->method(
'getId')->willReturn(555);
80 $this->storeManagerMock->expects($this->once())->method(
'getStore')->willReturn(
$store);
82 $this->transportBuilderMock->expects($this->once())
83 ->method(
'setTemplateIdentifier')
84 ->will($this->returnSelf());
86 $this->transportBuilderMock->expects($this->once())
87 ->method(
'setTemplateOptions')
92 ->will($this->returnSelf());
94 $this->transportBuilderMock->expects($this->once())
95 ->method(
'setTemplateVars')
97 ->will($this->returnSelf());
99 $this->transportBuilderMock->expects($this->once())
101 ->will($this->returnSelf());
103 $this->transportBuilderMock->expects($this->once())
105 ->will($this->returnSelf());
107 $this->transportBuilderMock->expects($this->once())
108 ->method(
'setReplyTo')
110 ->will($this->returnSelf());
112 $this->transportBuilderMock->expects($this->once())
113 ->method(
'getTransport')
114 ->willReturn($transport);
116 $transport->expects($this->once())
117 ->method(
'sendMessage');
119 $this->inlineTranslationMock->expects($this->once())
122 $this->inlineTranslationMock->expects($this->once())
125 $this->mail->send(
$email, $templateVars);