@@ -59,10 +59,11 @@ protected function setUp()
5959 * @param int $configValue
6060 * @param bool|null $forceSyncMode
6161 * @param bool|null $emailSendingResult
62- * @dataProvider sendDataProvider
62+ * @param $senderSendException
6363 * @return void
64+ * @dataProvider sendDataProvider
6465 */
65- public function testSend ($ configValue , $ forceSyncMode , $ emailSendingResult )
66+ public function testSend ($ configValue , $ forceSyncMode , $ emailSendingResult, $ senderSendException )
6667 {
6768 $ address = 'address_test ' ;
6869 $ configPath = 'sales_email/general/async_sending ' ;
@@ -122,19 +123,23 @@ public function testSend($configValue, $forceSyncMode, $emailSendingResult)
122123
123124 $ this ->senderMock ->expects ($ this ->once ())->method ('send ' );
124125
125- $ this ->senderMock ->expects ($ this ->once ())->method ('sendCopyTo ' );
126+ if ($ senderSendException ) {
127+ $ this ->checkSenderSendExceptionCase ();
128+ } else {
129+ $ this ->senderMock ->expects ($ this ->once ())->method ('sendCopyTo ' );
126130
127- $ this ->orderMock ->expects ($ this ->once ())
128- ->method ('setEmailSent ' )
129- ->with (true );
131+ $ this ->orderMock ->expects ($ this ->once ())
132+ ->method ('setEmailSent ' )
133+ ->with (true );
130134
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 ' ]);
134138
135- $ this ->assertTrue (
136- $ this ->sender ->send ($ this ->orderMock )
137- );
139+ $ this ->assertTrue (
140+ $ this ->sender ->send ($ this ->orderMock )
141+ );
142+ }
138143 } else {
139144 $ this ->orderResourceMock ->expects ($ this ->once ())
140145 ->method ('saveAttribute ' )
@@ -155,19 +160,42 @@ public function testSend($configValue, $forceSyncMode, $emailSendingResult)
155160 }
156161 }
157162
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+
158183 /**
159184 * @return array
160185 */
161186 public function sendDataProvider ()
162187 {
163188 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 ]
171199 ];
172200 }
173201
0 commit comments