6
6
7
7
namespace Magento \Sales \Test \Unit \Model \Order \Email ;
8
8
9
- use Magento \Framework \Mail \Template \TransportBuilderByStore ;
10
9
use Magento \Sales \Model \Order \Email \SenderBuilder ;
11
10
12
11
class SenderBuilderTest extends \PHPUnit \Framework \TestCase
@@ -36,11 +35,6 @@ class SenderBuilderTest extends \PHPUnit\Framework\TestCase
36
35
*/
37
36
private $ storeMock ;
38
37
39
- /**
40
- * @var \PHPUnit_Framework_MockObject_MockObject
41
- */
42
- private $ transportBuilderByStore ;
43
-
44
38
protected function setUp ()
45
39
{
46
40
$ templateId = 'test_template_id ' ;
@@ -82,11 +76,10 @@ protected function setUp()
82
76
'setTemplateIdentifier ' ,
83
77
'setTemplateOptions ' ,
84
78
'setTemplateVars ' ,
79
+ 'setFromByScope ' ,
85
80
]
86
81
);
87
82
88
- $ this ->transportBuilderByStore = $ this ->createMock (TransportBuilderByStore::class);
89
-
90
83
$ this ->templateContainerMock ->expects ($ this ->once ())
91
84
->method ('getTemplateId ' )
92
85
->will ($ this ->returnValue ($ templateId ));
@@ -109,9 +102,9 @@ protected function setUp()
109
102
$ this ->identityContainerMock ->expects ($ this ->once ())
110
103
->method ('getEmailIdentity ' )
111
104
->will ($ this ->returnValue ($ emailIdentity ));
112
- $ this ->transportBuilderByStore ->expects ($ this ->once ())
113
- ->method ('setFromByStore ' )
114
- ->with ($ this ->equalTo ($ emailIdentity ));
105
+ $ this ->transportBuilder ->expects ($ this ->once ())
106
+ ->method ('setFromByScope ' )
107
+ ->with ($ this ->equalTo ($ emailIdentity ), 1 );
115
108
116
109
$ this ->identityContainerMock ->expects ($ this ->once ())
117
110
->method ('getEmailCopyTo ' )
@@ -120,15 +113,16 @@ protected function setUp()
120
113
$ this ->senderBuilder = new SenderBuilder (
121
114
$ this ->templateContainerMock ,
122
115
$ this ->identityContainerMock ,
123
- $ this ->transportBuilder ,
124
- $ this ->transportBuilderByStore
116
+ $ this ->transportBuilder
125
117
);
126
118
}
127
119
128
120
public function testSend ()
129
121
{
130
122
$ customerName = 'test_name ' ;
131
123
$ customerEmail = 'test_email ' ;
124
+ $ identity = 'email_identity_test ' ;
125
+
132
126
$ transportMock = $ this ->createMock (
133
127
\Magento \Sales \Test \Unit \Model \Order \Email \Stub \TransportInterfaceMock::class
134
128
);
@@ -151,6 +145,9 @@ public function testSend()
151
145
$ this ->storeMock ->expects ($ this ->once ())
152
146
->method ('getId ' )
153
147
->willReturn (1 );
148
+ $ this ->transportBuilder ->expects ($ this ->once ())
149
+ ->method ('setFromByScope ' )
150
+ ->with ($ identity , 1 );
154
151
$ this ->transportBuilder ->expects ($ this ->once ())
155
152
->method ('addTo ' )
156
153
->with ($ this ->equalTo ($ customerEmail ), $ this ->equalTo ($ customerName ));
@@ -164,6 +161,7 @@ public function testSend()
164
161
165
162
public function testSendCopyTo ()
166
163
{
164
+ $ identity = 'email_identity_test ' ;
167
165
$ transportMock = $ this ->createMock (
168
166
\Magento \Sales \Test \Unit \Model \Order \Email \Stub \TransportInterfaceMock::class
169
167
);
@@ -177,6 +175,9 @@ public function testSendCopyTo()
177
175
$ this ->transportBuilder ->expects ($ this ->once ())
178
176
->method ('addTo ' )
179
177
->with ($ this ->equalTo ('example@mail.com ' ));
178
+ $ this ->transportBuilder ->expects ($ this ->once ())
179
+ ->method ('setFromByScope ' )
180
+ ->with ($ identity , 1 );
180
181
$ this ->identityContainerMock ->expects ($ this ->once ())
181
182
->method ('getStore ' )
182
183
->willReturn ($ this ->storeMock );
0 commit comments