Skip to content

Commit 70f3e2a

Browse files
author
Jeroen van Leusden
committed
Append shipment comment to shipment if appendComment is true
1 parent ad44399 commit 70f3e2a

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ public function create(
9090
$appendComment,
9191
$comment->getIsVisibleOnFront()
9292
);
93+
94+
if ($appendComment) {
95+
$shipment->setCustomerNote($comment->getComment());
96+
$shipment->setCustomerNoteNotify($appendComment);
97+
}
9398
}
9499

95100
return $shipment;

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

Lines changed: 6 additions & 2 deletions
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)
@@ -166,7 +166,7 @@ public function testCreate()
166166
if ($appendComment) {
167167
$comment = "New comment!";
168168
$visibleOnFront = true;
169-
$this->commentMock->expects($this->once())
169+
$this->commentMock->expects($this->exactly(2))
170170
->method('getComment')
171171
->willReturn($comment);
172172

@@ -178,6 +178,10 @@ public function testCreate()
178178
->method('addComment')
179179
->with($comment, $appendComment, $visibleOnFront)
180180
->willReturnSelf();
181+
182+
$this->shipmentMock->expects($this->once())
183+
->method('setCustomerNoteNotify')
184+
->with(true);
181185
}
182186

183187
$this->assertEquals(

0 commit comments

Comments
 (0)