Skip to content

Commit 3b30eba

Browse files
committed
ACP2E-2734: Emails are failing to send
1 parent 81e82c4 commit 3b30eba

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

app/code/Magento/Sales/Model/EmailSenderHandler.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ class EmailSenderHandler
7272
* @var string
7373
*/
7474
private $modifyStartFromDate;
75+
76+
/**
77+
* @var int
78+
*/
7579
private int $maxSendAttempts;
7680

7781
/**

app/code/Magento/Sales/Test/Unit/Model/EmailSenderHandlerTest.php

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ protected function setUp(): void
151151
* @param int $configValue
152152
* @param array|null $collectionItems
153153
* @param bool|null $emailSendingResult
154+
* @param int|null $expectedIsEmailSent
154155
*
155156
* @return void
156157
* @dataProvider executeDataProvider
@@ -159,7 +160,8 @@ protected function setUp(): void
159160
public function testExecute(
160161
int $configValue,
161162
?array $collectionItems,
162-
?bool $emailSendingResult
163+
?bool $emailSendingResult,
164+
?int $expectedIsEmailSent
163165
): void {
164166
$path = 'sales_email/general/async_sending';
165167

@@ -175,7 +177,12 @@ public function testExecute(
175177
->method('addFieldToFilter')
176178
->withConsecutive(
177179
['send_email', ['eq' => 1]],
178-
['email_sent', ['null' => true]],
180+
['email_sent',
181+
[
182+
['null' => true],
183+
['lteq' => -1]
184+
]
185+
],
179186
['created_at', ['from' => $fromDate]]
180187
);
181188

@@ -248,7 +255,7 @@ public function testExecute(
248255
$collectionItem
249256
->expects($this->once())
250257
->method('setEmailSent')
251-
->with($emailSendingResult)
258+
->with($expectedIsEmailSent)
252259
->willReturn($collectionItem);
253260

254261
$this->entityResource
@@ -280,22 +287,26 @@ public function executeDataProvider(): array
280287
[
281288
'configValue' => 1,
282289
'collectionItems' => [clone $entityModel],
283-
'emailSendingResult' => true
290+
'emailSendingResult' => true,
291+
'expectedIsEmailSent' => 1
284292
],
285293
[
286294
'configValue' => 1,
287295
'collectionItems' => [clone $entityModel],
288-
'emailSendingResult' => false
296+
'emailSendingResult' => false,
297+
'expectedIsEmailSent' => -2
289298
],
290299
[
291300
'configValue' => 1,
292301
'collectionItems' => [],
293-
'emailSendingResult' => null
302+
'emailSendingResult' => null,
303+
'expectedIsEmailSent' => 1
294304
],
295305
[
296306
'configValue' => 0,
297307
'collectionItems' => null,
298-
'emailSendingResult' => null
308+
'emailSendingResult' => null,
309+
'expectedIsEmailSent' => 1
299310
]
300311
];
301312
}

0 commit comments

Comments
 (0)