From 46cca389a36c0c1eb8c231a4c80fdec7f1568661 Mon Sep 17 00:00:00 2001 From: Jeroen van Leusden Date: Wed, 11 Oct 2017 20:36:47 +0200 Subject: [PATCH] Append shipment comment to shipment if appendComment is true --- .../Magento/Sales/Model/Order/ShipmentDocumentFactory.php | 5 +++++ .../Test/Unit/Model/Order/ShipmentDocumentFactoryTest.php | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Sales/Model/Order/ShipmentDocumentFactory.php b/app/code/Magento/Sales/Model/Order/ShipmentDocumentFactory.php index 8e46f26f7d9fc..6d9bffdd00771 100644 --- a/app/code/Magento/Sales/Model/Order/ShipmentDocumentFactory.php +++ b/app/code/Magento/Sales/Model/Order/ShipmentDocumentFactory.php @@ -101,6 +101,11 @@ public function create( $appendComment, $comment->getIsVisibleOnFront() ); + + if ($appendComment) { + $shipment->setCustomerNote($comment->getComment()); + $shipment->setCustomerNoteNotify($appendComment); + } } return $shipment; diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/ShipmentDocumentFactoryTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/ShipmentDocumentFactoryTest.php index 0d02c49b21c6b..e681edf3e542f 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/ShipmentDocumentFactoryTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/ShipmentDocumentFactoryTest.php @@ -92,7 +92,7 @@ protected function setUp() $this->shipmentMock = $this->getMockBuilder(ShipmentInterface::class) ->disableOriginalConstructor() - ->setMethods(['addComment', 'addTrack']) + ->setMethods(['addComment', 'addTrack', 'setCustomerNote', 'setCustomerNoteNotify']) ->getMockForAbstractClass(); $this->hydratorPoolMock = $this->getMockBuilder(HydratorPool::class) @@ -160,7 +160,7 @@ public function testCreate() if ($appendComment) { $comment = "New comment!"; $visibleOnFront = true; - $this->commentMock->expects($this->once()) + $this->commentMock->expects($this->exactly(2)) ->method('getComment') ->willReturn($comment); @@ -172,6 +172,10 @@ public function testCreate() ->method('addComment') ->with($comment, $appendComment, $visibleOnFront) ->willReturnSelf(); + + $this->shipmentMock->expects($this->once()) + ->method('setCustomerNoteNotify') + ->with(true); } $this->assertEquals(