Skip to content

Commit 78dd01a

Browse files
author
Jeroen
committed
Check if copy method is copy before sending comment email
1 parent 5d8908c commit 78dd01a

File tree

5 files changed

+17
-8
lines changed

5 files changed

+17
-8
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ protected function checkAndSend(Order $order, $notify = true)
3535

3636
if ($notify) {
3737
$sender->send();
38-
} else {
38+
} elseif ($this->identityContainer->getCopyMethod() === 'copy') {
3939
// Email copies are sent as separated emails if their copy method
4040
// is 'copy' or a customer should not be notified
4141
$sender->sendCopyTo();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public function stepIdentityContainerInit($identityMockClassName)
192192
{
193193
$this->identityContainerMock = $this->getMockBuilder($identityMockClassName)
194194
->disableOriginalConstructor()
195-
->onlyMethods(['getStore', 'isEnabled', 'getConfigValue', 'getTemplateId', 'getGuestTemplateId'])
195+
->onlyMethods(['getStore', 'isEnabled', 'getConfigValue', 'getTemplateId', 'getGuestTemplateId', 'getCopyMethod'])
196196
->getMock();
197197
$this->identityContainerMock->expects($this->any())
198198
->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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function testSendFalse()
6565
$this->assertFalse($result);
6666
}
6767

68-
public function testSendTrueWithCustomerCopy()
68+
public function testSendTrueWithoutCustomerCopy()
6969
{
7070
$billingAddress = $this->addressMock;
7171
$this->stepAddressFormat($billingAddress);
@@ -110,7 +110,7 @@ public function testSendTrueWithCustomerCopy()
110110
$this->assertTrue($result);
111111
}
112112

113-
public function testSendTrueWithoutCustomerCopy()
113+
public function testSendTrueWithCustomerCopy()
114114
{
115115
$billingAddress = $this->addressMock;
116116
$customerName = 'Test Customer';
@@ -132,6 +132,9 @@ public function testSendTrueWithoutCustomerCopy()
132132
$this->identityContainerMock->expects($this->once())
133133
->method('isEnabled')
134134
->willReturn(true);
135+
$this->identityContainerMock->expects($this->once())
136+
->method('getCopyMethod')
137+
->willReturn('copy');
135138
$this->templateContainerMock->expects($this->once())
136139
->method('setTemplateVars')
137140
->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)