Skip to content

Commit ef74d31

Browse files
ENGCOM-8348: Check if copy method is copy before sending comment email #29911
- Merge Pull Request #29911 from JeroenVanLeusden/magento2:patch-1 - Merged commits: 1. 78dd01a 2. 35bbc82 3. 902e1a2 4. c7c4ad6
2 parents 32ed03c + c7c4ad6 commit ef74d31

File tree

5 files changed

+20
-10
lines changed

5 files changed

+20
-10
lines changed

app/code/Magento/Sales/Model/Order/Email/NotifySender.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
/**
1212
* Class NotifySender
13+
* phpcs:disable Magento2.Classes.AbstractApi
1314
* @api
1415
* @since 100.0.2
1516
*/
@@ -35,7 +36,7 @@ protected function checkAndSend(Order $order, $notify = true)
3536

3637
if ($notify) {
3738
$sender->send();
38-
} else {
39+
} elseif ($this->identityContainer->getCopyMethod() === 'copy') {
3940
// Email copies are sent as separated emails if their copy method
4041
// is 'copy' or a customer should not be notified
4142
$sender->sendCopyTo();

app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/AbstractSenderTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,9 @@ public function stepIdentityContainerInit($identityMockClassName)
192192
{
193193
$this->identityContainerMock = $this->getMockBuilder($identityMockClassName)
194194
->disableOriginalConstructor()
195-
->onlyMethods(['getStore', 'isEnabled', 'getConfigValue', 'getTemplateId', 'getGuestTemplateId'])
195+
->onlyMethods(
196+
['getStore', 'isEnabled', 'getConfigValue', 'getTemplateId', 'getGuestTemplateId', 'getCopyMethod']
197+
)
196198
->getMock();
197199
$this->identityContainerMock->expects($this->any())
198200
->method('getStore')

app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/CreditmemoCommentSenderTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function testSendVirtualOrder()
9797
$this->assertFalse($result);
9898
}
9999

100-
public function testSendTrueWithCustomerCopy()
100+
public function testSendTrueWithoutCustomerCopy()
101101
{
102102
$billingAddress = $this->addressMock;
103103
$comment = 'comment_test';
@@ -140,7 +140,7 @@ public function testSendTrueWithCustomerCopy()
140140
$this->assertTrue($result);
141141
}
142142

143-
public function testSendTrueWithoutCustomerCopy()
143+
public function testSendTrueWithCustomerCopy()
144144
{
145145
$billingAddress = $this->addressMock;
146146
$comment = 'comment_test';
@@ -161,6 +161,9 @@ public function testSendTrueWithoutCustomerCopy()
161161
$this->identityContainerMock->expects($this->once())
162162
->method('isEnabled')
163163
->willReturn(true);
164+
$this->identityContainerMock->expects($this->once())
165+
->method('getCopyMethod')
166+
->willReturn('copy');
164167
$this->templateContainerMock->expects($this->once())
165168
->method('setTemplateVars')
166169
->with(

app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/InvoiceCommentSenderTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ protected function setUp(): void
3131
$this->stepMockSetup();
3232
$this->paymentHelper = $this->createPartialMock(Data::class, ['getInfoBlockHtml']);
3333

34-
$this->invoiceResource = $this->createMock(Invoice::class);
35-
3634
$this->stepIdentityContainerInit(InvoiceCommentIdentity::class);
3735

3836
$this->addressRenderer->expects($this->any())->method('format')->willReturn(1);
@@ -65,7 +63,7 @@ public function testSendFalse()
6563
$this->assertFalse($result);
6664
}
6765

68-
public function testSendTrueWithCustomerCopy()
66+
public function testSendTrueWithoutCustomerCopy()
6967
{
7068
$billingAddress = $this->addressMock;
7169
$this->stepAddressFormat($billingAddress);
@@ -110,7 +108,7 @@ public function testSendTrueWithCustomerCopy()
110108
$this->assertTrue($result);
111109
}
112110

113-
public function testSendTrueWithoutCustomerCopy()
111+
public function testSendTrueWithCustomerCopy()
114112
{
115113
$billingAddress = $this->addressMock;
116114
$customerName = 'Test Customer';
@@ -132,6 +130,9 @@ public function testSendTrueWithoutCustomerCopy()
132130
$this->identityContainerMock->expects($this->once())
133131
->method('isEnabled')
134132
->willReturn(true);
133+
$this->identityContainerMock->expects($this->once())
134+
->method('getCopyMethod')
135+
->willReturn('copy');
135136
$this->templateContainerMock->expects($this->once())
136137
->method('setTemplateVars')
137138
->with(

app/code/Magento/Sales/Test/Unit/Model/Order/Email/Sender/ShipmentCommentSenderTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function testSendFalse()
5858
$this->assertFalse($result);
5959
}
6060

61-
public function testSendTrueWithCustomerCopy()
61+
public function testSendTrueWithoutCustomerCopy()
6262
{
6363
$billingAddress = $this->addressMock;
6464
$comment = 'comment_test';
@@ -101,7 +101,7 @@ public function testSendTrueWithCustomerCopy()
101101
$this->assertTrue($result);
102102
}
103103

104-
public function testSendTrueWithoutCustomerCopy()
104+
public function testSendTrueWithCustomerCopy()
105105
{
106106
$billingAddress = $this->addressMock;
107107
$comment = 'comment_test';
@@ -116,6 +116,9 @@ public function testSendTrueWithoutCustomerCopy()
116116
$this->identityContainerMock->expects($this->once())
117117
->method('isEnabled')
118118
->willReturn(true);
119+
$this->identityContainerMock->expects($this->once())
120+
->method('getCopyMethod')
121+
->willReturn('copy');
119122
$this->orderMock->expects($this->any())
120123
->method('getCustomerName')
121124
->willReturn($customerName);

0 commit comments

Comments
 (0)