Skip to content

Commit 46cca38

Browse files
author
Jeroen van Leusden
committed
Append shipment comment to shipment if appendComment is true
1 parent d2cbddd commit 46cca38

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

app/code/Magento/Sales/Model/Order/ShipmentDocumentFactory.php

+5
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ public function create(
101101
$appendComment,
102102
$comment->getIsVisibleOnFront()
103103
);
104+
105+
if ($appendComment) {
106+
$shipment->setCustomerNote($comment->getComment());
107+
$shipment->setCustomerNoteNotify($appendComment);
108+
}
104109
}
105110

106111
return $shipment;

app/code/Magento/Sales/Test/Unit/Model/Order/ShipmentDocumentFactoryTest.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ protected function setUp()
9292

9393
$this->shipmentMock = $this->getMockBuilder(ShipmentInterface::class)
9494
->disableOriginalConstructor()
95-
->setMethods(['addComment', 'addTrack'])
95+
->setMethods(['addComment', 'addTrack', 'setCustomerNote', 'setCustomerNoteNotify'])
9696
->getMockForAbstractClass();
9797

9898
$this->hydratorPoolMock = $this->getMockBuilder(HydratorPool::class)
@@ -160,7 +160,7 @@ public function testCreate()
160160
if ($appendComment) {
161161
$comment = "New comment!";
162162
$visibleOnFront = true;
163-
$this->commentMock->expects($this->once())
163+
$this->commentMock->expects($this->exactly(2))
164164
->method('getComment')
165165
->willReturn($comment);
166166

@@ -172,6 +172,10 @@ public function testCreate()
172172
->method('addComment')
173173
->with($comment, $appendComment, $visibleOnFront)
174174
->willReturnSelf();
175+
176+
$this->shipmentMock->expects($this->once())
177+
->method('setCustomerNoteNotify')
178+
->with(true);
175179
}
176180

177181
$this->assertEquals(

0 commit comments

Comments
 (0)