Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if copy method is copy before sending comment email #29911

Merged
merged 4 commits into from
Oct 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/code/Magento/Sales/Model/Order/Email/NotifySender.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

/**
* Class NotifySender
* phpcs:disable Magento2.Classes.AbstractApi
* @api
* @since 100.0.2
*/
Expand All @@ -35,7 +36,7 @@ protected function checkAndSend(Order $order, $notify = true)

if ($notify) {
$sender->send();
} else {
} elseif ($this->identityContainer->getCopyMethod() === 'copy') {
// Email copies are sent as separated emails if their copy method
// is 'copy' or a customer should not be notified
$sender->sendCopyTo();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,9 @@ public function stepIdentityContainerInit($identityMockClassName)
{
$this->identityContainerMock = $this->getMockBuilder($identityMockClassName)
->disableOriginalConstructor()
->onlyMethods(['getStore', 'isEnabled', 'getConfigValue', 'getTemplateId', 'getGuestTemplateId'])
->onlyMethods(
['getStore', 'isEnabled', 'getConfigValue', 'getTemplateId', 'getGuestTemplateId', 'getCopyMethod']
)
->getMock();
$this->identityContainerMock->expects($this->any())
->method('getStore')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function testSendVirtualOrder()
$this->assertFalse($result);
}

public function testSendTrueWithCustomerCopy()
public function testSendTrueWithoutCustomerCopy()
{
$billingAddress = $this->addressMock;
$comment = 'comment_test';
Expand Down Expand Up @@ -140,7 +140,7 @@ public function testSendTrueWithCustomerCopy()
$this->assertTrue($result);
}

public function testSendTrueWithoutCustomerCopy()
public function testSendTrueWithCustomerCopy()
{
$billingAddress = $this->addressMock;
$comment = 'comment_test';
Expand All @@ -161,6 +161,9 @@ public function testSendTrueWithoutCustomerCopy()
$this->identityContainerMock->expects($this->once())
->method('isEnabled')
->willReturn(true);
$this->identityContainerMock->expects($this->once())
->method('getCopyMethod')
->willReturn('copy');
$this->templateContainerMock->expects($this->once())
->method('setTemplateVars')
->with(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ protected function setUp(): void
$this->stepMockSetup();
$this->paymentHelper = $this->createPartialMock(Data::class, ['getInfoBlockHtml']);

$this->invoiceResource = $this->createMock(Invoice::class);

$this->stepIdentityContainerInit(InvoiceCommentIdentity::class);

$this->addressRenderer->expects($this->any())->method('format')->willReturn(1);
Expand Down Expand Up @@ -65,7 +63,7 @@ public function testSendFalse()
$this->assertFalse($result);
}

public function testSendTrueWithCustomerCopy()
public function testSendTrueWithoutCustomerCopy()
{
$billingAddress = $this->addressMock;
$this->stepAddressFormat($billingAddress);
Expand Down Expand Up @@ -110,7 +108,7 @@ public function testSendTrueWithCustomerCopy()
$this->assertTrue($result);
}

public function testSendTrueWithoutCustomerCopy()
public function testSendTrueWithCustomerCopy()
{
$billingAddress = $this->addressMock;
$customerName = 'Test Customer';
Expand All @@ -132,6 +130,9 @@ public function testSendTrueWithoutCustomerCopy()
$this->identityContainerMock->expects($this->once())
->method('isEnabled')
->willReturn(true);
$this->identityContainerMock->expects($this->once())
->method('getCopyMethod')
->willReturn('copy');
$this->templateContainerMock->expects($this->once())
->method('setTemplateVars')
->with(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function testSendFalse()
$this->assertFalse($result);
}

public function testSendTrueWithCustomerCopy()
public function testSendTrueWithoutCustomerCopy()
{
$billingAddress = $this->addressMock;
$comment = 'comment_test';
Expand Down Expand Up @@ -101,7 +101,7 @@ public function testSendTrueWithCustomerCopy()
$this->assertTrue($result);
}

public function testSendTrueWithoutCustomerCopy()
public function testSendTrueWithCustomerCopy()
{
$billingAddress = $this->addressMock;
$comment = 'comment_test';
Expand All @@ -116,6 +116,9 @@ public function testSendTrueWithoutCustomerCopy()
$this->identityContainerMock->expects($this->once())
->method('isEnabled')
->willReturn(true);
$this->identityContainerMock->expects($this->once())
->method('getCopyMethod')
->willReturn('copy');
$this->orderMock->expects($this->any())
->method('getCustomerName')
->willReturn($customerName);
Expand Down