3
3
* Copyright © Magento, Inc. All rights reserved.
4
4
* See COPYING.txt for license details.
5
5
*/
6
+
6
7
namespace Magento \Sales \Test \Unit \Model \Order \Email ;
7
8
8
9
use Magento \Sales \Model \Order \Email \SenderBuilder ;
@@ -29,6 +30,11 @@ class SenderBuilderTest extends \PHPUnit\Framework\TestCase
29
30
*/
30
31
protected $ transportBuilder ;
31
32
33
+ /**
34
+ * @var \PHPUnit_Framework_MockObject_MockObject
35
+ */
36
+ private $ storeMock ;
37
+
32
38
protected function setUp ()
33
39
{
34
40
$ templateId = 'test_template_id ' ;
@@ -42,7 +48,11 @@ protected function setUp()
42
48
['getTemplateVars ' , 'getTemplateOptions ' , 'getTemplateId ' ]
43
49
);
44
50
45
- $ this ->storeMock = $ this ->createPartialMock (\Magento \Store \Model \Store::class, ['getStoreId ' , '__wakeup ' ]);
51
+ $ this ->storeMock = $ this ->createPartialMock (\Magento \Store \Model \Store::class, [
52
+ 'getStoreId ' ,
53
+ '__wakeup ' ,
54
+ 'getId ' ,
55
+ ]);
46
56
47
57
$ this ->identityContainerMock = $ this ->createPartialMock (
48
58
\Magento \Sales \Model \Order \Email \Container \ShipmentIdentity::class,
@@ -52,14 +62,20 @@ protected function setUp()
52
62
'getCustomerName ' ,
53
63
'getTemplateOptions ' ,
54
64
'getEmailCopyTo ' ,
55
- 'getCopyMethod '
65
+ 'getCopyMethod ' ,
66
+ 'getStore ' ,
56
67
]
57
68
);
58
69
59
- $ this ->transportBuilder = $ this ->createPartialMock (\Magento \Framework \Mail \Template \TransportBuilder::class, [
60
- 'addTo ' , 'addBcc ' , 'getTransport ' ,
61
- 'setTemplateIdentifier ' , 'setTemplateOptions ' , 'setTemplateVars ' ,
62
- 'setFrom ' ,
70
+ $ this ->transportBuilder = $ this ->createPartialMock (\Magento \Framework \Mail \Template \TransportBuilder::class,
71
+ [
72
+ 'addTo ' ,
73
+ 'addBcc ' ,
74
+ 'getTransport ' ,
75
+ 'setTemplateIdentifier ' ,
76
+ 'setTemplateOptions ' ,
77
+ 'setTemplateVars ' ,
78
+ 'setFromByStore ' ,
63
79
]);
64
80
65
81
$ this ->templateContainerMock ->expects ($ this ->once ())
@@ -85,7 +101,7 @@ protected function setUp()
85
101
->method ('getEmailIdentity ' )
86
102
->will ($ this ->returnValue ($ emailIdentity ));
87
103
$ this ->transportBuilder ->expects ($ this ->once ())
88
- ->method ('setFrom ' )
104
+ ->method ('setFromByStore ' )
89
105
->with ($ this ->equalTo ($ emailIdentity ));
90
106
91
107
$ this ->identityContainerMock ->expects ($ this ->once ())
@@ -119,6 +135,12 @@ public function testSend()
119
135
$ this ->identityContainerMock ->expects ($ this ->once ())
120
136
->method ('getCustomerName ' )
121
137
->will ($ this ->returnValue ($ customerName ));
138
+ $ this ->identityContainerMock ->expects ($ this ->once ())
139
+ ->method ('getStore ' )
140
+ ->willReturn ($ this ->storeMock );
141
+ $ this ->storeMock ->expects ($ this ->once ())
142
+ ->method ('getId ' )
143
+ ->willReturn (1 );
122
144
$ this ->transportBuilder ->expects ($ this ->once ())
123
145
->method ('addTo ' )
124
146
->with ($ this ->equalTo ($ customerEmail ), $ this ->equalTo ($ customerName ));
@@ -145,7 +167,12 @@ public function testSendCopyTo()
145
167
$ this ->transportBuilder ->expects ($ this ->once ())
146
168
->method ('addTo ' )
147
169
->
with (
$ this ->
equalTo (
'[email protected] ' ));
148
-
170
+ $ this ->identityContainerMock ->expects ($ this ->once ())
171
+ ->method ('getStore ' )
172
+ ->willReturn ($ this ->storeMock );
173
+ $ this ->storeMock ->expects ($ this ->once ())
174
+ ->method ('getId ' )
175
+ ->willReturn (1 );
149
176
$ this ->transportBuilder ->expects ($ this ->once ())
150
177
->method ('getTransport ' )
151
178
->will ($ this ->returnValue ($ transportMock ));
0 commit comments