@@ -53,10 +53,11 @@ protected function setUp()
53
53
* @param int $configValue
54
54
* @param bool|null $forceSyncMode
55
55
* @param bool|null $emailSendingResult
56
- * @dataProvider sendDataProvider
56
+ * @param $senderSendException
57
57
* @return void
58
+ * @dataProvider sendDataProvider
58
59
*/
59
- public function testSend ($ configValue , $ forceSyncMode , $ emailSendingResult )
60
+ public function testSend ($ configValue , $ forceSyncMode , $ emailSendingResult, $ senderSendException )
60
61
{
61
62
$ address = 'address_test ' ;
62
63
$ configPath = 'sales_email/general/async_sending ' ;
@@ -110,19 +111,23 @@ public function testSend($configValue, $forceSyncMode, $emailSendingResult)
110
111
111
112
$ this ->senderMock ->expects ($ this ->once ())->method ('send ' );
112
113
113
- $ this ->senderMock ->expects ($ this ->once ())->method ('sendCopyTo ' );
114
+ if ($ senderSendException ) {
115
+ $ this ->checkSenderSendExceptionCase ();
116
+ } else {
117
+ $ this ->senderMock ->expects ($ this ->once ())->method ('sendCopyTo ' );
114
118
115
- $ this ->orderMock ->expects ($ this ->once ())
116
- ->method ('setEmailSent ' )
117
- ->with (true );
119
+ $ this ->orderMock ->expects ($ this ->once ())
120
+ ->method ('setEmailSent ' )
121
+ ->with (true );
118
122
119
- $ this ->orderResourceMock ->expects ($ this ->once ())
120
- ->method ('saveAttribute ' )
121
- ->with ($ this ->orderMock , ['send_email ' , 'email_sent ' ]);
123
+ $ this ->orderResourceMock ->expects ($ this ->once ())
124
+ ->method ('saveAttribute ' )
125
+ ->with ($ this ->orderMock , ['send_email ' , 'email_sent ' ]);
122
126
123
- $ this ->assertTrue (
124
- $ this ->sender ->send ($ this ->orderMock )
125
- );
127
+ $ this ->assertTrue (
128
+ $ this ->sender ->send ($ this ->orderMock )
129
+ );
130
+ }
126
131
} else {
127
132
$ this ->orderResourceMock ->expects ($ this ->once ())
128
133
->method ('saveAttribute ' )
@@ -146,19 +151,42 @@ public function testSend($configValue, $forceSyncMode, $emailSendingResult)
146
151
}
147
152
}
148
153
154
+ /**
155
+ * Methods check case when method "send" in "senderMock" throw exception.
156
+ *
157
+ * @return void
158
+ */
159
+ protected function checkSenderSendExceptionCase ()
160
+ {
161
+ $ this ->senderMock ->expects ($ this ->once ())
162
+ ->method ('send ' )
163
+ ->willThrowException (new \Exception ('exception ' ));
164
+
165
+ $ this ->orderResourceMock ->expects ($ this ->once ())
166
+ ->method ('saveAttribute ' )
167
+ ->with ($ this ->orderMock , 'send_email ' );
168
+
169
+ $ this ->assertFalse (
170
+ $ this ->sender ->send ($ this ->orderMock )
171
+ );
172
+ }
173
+
149
174
/**
150
175
* @return array
151
176
*/
152
177
public function sendDataProvider ()
153
178
{
154
179
return [
155
- [0 , 0 , true ],
156
- [0 , 0 , true ],
157
- [0 , 0 , false ],
158
- [0 , 0 , false ],
159
- [0 , 1 , true ],
160
- [0 , 1 , true ],
161
- [1 , null , null , null ]
180
+ [0 , 0 , true , false ],
181
+ [0 , 0 , true , false ],
182
+ [0 , 0 , true , true ],
183
+ [0 , 0 , false , false ],
184
+ [0 , 0 , false , false ],
185
+ [0 , 0 , false , true ],
186
+ [0 , 1 , true , false ],
187
+ [0 , 1 , true , false ],
188
+ [0 , 1 , true , false ],
189
+ [1 , null , null , false ]
162
190
];
163
191
}
164
192
0 commit comments