File tree Expand file tree Collapse file tree 2 files changed +15
-32
lines changed Expand file tree Collapse file tree 2 files changed +15
-32
lines changed Original file line number Diff line number Diff line change @@ -132,20 +132,11 @@ public function sendEmails()
132132
133133 /** @var \Magento\Sales\Model\AbstractModel $item */
134134 foreach ($ entityCollection ->getItems () as $ item ) {
135- if ($ this ->emailSender ->send ($ item , true )) {
136- $ this ->entityResource ->saveAttribute (
137- $ item ->setEmailSent (true ),
138- 'email_sent '
139- );
140- } else {
141- // When the email is failed to send, the email_sent attribute
142- // should be set to false, preventing this email from being
143- // sent over and over again in the next cron runs.
144- $ this ->entityResource ->saveAttribute (
145- $ item ->setEmailSent (false ),
146- 'email_sent '
147- );
148- }
135+ $ isEmailSent = $ this ->emailSender ->send ($ item , true );
136+ $ this ->entityResource ->saveAttribute (
137+ $ item ->setEmailSent ($ isEmailSent ),
138+ 'email_sent '
139+ );
149140 }
150141 }
151142 }
Original file line number Diff line number Diff line change @@ -245,24 +245,16 @@ public function testExecute(
245245 ->method ('isEnabled ' )
246246 ->willReturn (true );
247247
248- if ($ emailSendingResult ) {
249- $ collectionItem
250- ->expects ($ this ->once ())
251- ->method ('setEmailSent ' )
252- ->with (true )
253- ->willReturn ($ collectionItem );
254-
255- $ this ->entityResource
256- ->expects ($ this ->once ())
257- ->method ('saveAttribute ' )
258- ->with ($ collectionItem );
259- } else {
260- $ collectionItem
261- ->expects ($ this ->once ())
262- ->method ('setEmailSent ' )
263- ->with (false )
264- ->willReturn ($ collectionItem );
265- }
248+ $ collectionItem
249+ ->expects ($ this ->once ())
250+ ->method ('setEmailSent ' )
251+ ->with ($ emailSendingResult )
252+ ->willReturn ($ collectionItem );
253+
254+ $ this ->entityResource
255+ ->expects ($ this ->once ())
256+ ->method ('saveAttribute ' )
257+ ->with ($ collectionItem );
266258 }
267259 }
268260
You can’t perform that action at this time.
0 commit comments