@@ -59,10 +59,11 @@ protected function setUp()
59
59
* @param int $configValue
60
60
* @param bool|null $forceSyncMode
61
61
* @param bool|null $emailSendingResult
62
- * @dataProvider sendDataProvider
62
+ * @param $senderSendException
63
63
* @return void
64
+ * @dataProvider sendDataProvider
64
65
*/
65
- public function testSend ($ configValue , $ forceSyncMode , $ emailSendingResult )
66
+ public function testSend ($ configValue , $ forceSyncMode , $ emailSendingResult, $ senderSendException )
66
67
{
67
68
$ address = 'address_test ' ;
68
69
$ configPath = 'sales_email/general/async_sending ' ;
@@ -122,19 +123,23 @@ public function testSend($configValue, $forceSyncMode, $emailSendingResult)
122
123
123
124
$ this ->senderMock ->expects ($ this ->once ())->method ('send ' );
124
125
125
- $ this ->senderMock ->expects ($ this ->once ())->method ('sendCopyTo ' );
126
+ if ($ senderSendException ) {
127
+ $ this ->checkSenderSendExceptionCase ();
128
+ } else {
129
+ $ this ->senderMock ->expects ($ this ->once ())->method ('sendCopyTo ' );
126
130
127
- $ this ->orderMock ->expects ($ this ->once ())
128
- ->method ('setEmailSent ' )
129
- ->with (true );
131
+ $ this ->orderMock ->expects ($ this ->once ())
132
+ ->method ('setEmailSent ' )
133
+ ->with (true );
130
134
131
- $ this ->orderResourceMock ->expects ($ this ->once ())
132
- ->method ('saveAttribute ' )
133
- ->with ($ this ->orderMock , ['send_email ' , 'email_sent ' ]);
135
+ $ this ->orderResourceMock ->expects ($ this ->once ())
136
+ ->method ('saveAttribute ' )
137
+ ->with ($ this ->orderMock , ['send_email ' , 'email_sent ' ]);
134
138
135
- $ this ->assertTrue (
136
- $ this ->sender ->send ($ this ->orderMock )
137
- );
139
+ $ this ->assertTrue (
140
+ $ this ->sender ->send ($ this ->orderMock )
141
+ );
142
+ }
138
143
} else {
139
144
$ this ->orderResourceMock ->expects ($ this ->once ())
140
145
->method ('saveAttribute ' )
@@ -155,19 +160,42 @@ public function testSend($configValue, $forceSyncMode, $emailSendingResult)
155
160
}
156
161
}
157
162
163
+ /**
164
+ * Methods check case when method "send" in "senderMock" throw exception.
165
+ *
166
+ * @return void
167
+ */
168
+ protected function checkSenderSendExceptionCase ()
169
+ {
170
+ $ this ->senderMock ->expects ($ this ->once ())
171
+ ->method ('send ' )
172
+ ->willThrowException (new \Exception ('exception ' ));
173
+
174
+ $ this ->orderResourceMock ->expects ($ this ->once ())
175
+ ->method ('saveAttribute ' )
176
+ ->with ($ this ->orderMock , 'send_email ' );
177
+
178
+ $ this ->assertFalse (
179
+ $ this ->sender ->send ($ this ->orderMock )
180
+ );
181
+ }
182
+
158
183
/**
159
184
* @return array
160
185
*/
161
186
public function sendDataProvider ()
162
187
{
163
188
return [
164
- [0 , 0 , true ],
165
- [0 , 0 , true ],
166
- [0 , 0 , false ],
167
- [0 , 0 , false ],
168
- [0 , 1 , true ],
169
- [0 , 1 , true ],
170
- [1 , null , null , null ]
189
+ [0 , 0 , true , false ],
190
+ [0 , 0 , true , false ],
191
+ [0 , 0 , true , true ],
192
+ [0 , 0 , false , false ],
193
+ [0 , 0 , false , false ],
194
+ [0 , 0 , false , true ],
195
+ [0 , 1 , true , false ],
196
+ [0 , 1 , true , false ],
197
+ [0 , 1 , true , false ],
198
+ [1 , null , null , false ]
171
199
];
172
200
}
173
201
0 commit comments