diff --git a/app/code/Magento/Sales/Model/RefundInvoice.php b/app/code/Magento/Sales/Model/RefundInvoice.php index c9d23d98e9f5e..e643f435be80b 100644 --- a/app/code/Magento/Sales/Model/RefundInvoice.php +++ b/app/code/Magento/Sales/Model/RefundInvoice.php @@ -175,6 +175,7 @@ public function execute( $invoice->getBaseTotalRefunded() + $creditmemo->getBaseGrandTotal() ); } + $creditmemo->setInvoiceId($invoice->getId()); $this->invoiceRepository->save($invoice); $order = $this->orderRepository->save($order); $creditmemo = $this->creditmemoRepository->save($creditmemo); diff --git a/app/code/Magento/Sales/Test/Unit/Model/RefundInvoiceTest.php b/app/code/Magento/Sales/Test/Unit/Model/RefundInvoiceTest.php index 5a8c1032cd4fc..821532e263479 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/RefundInvoiceTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/RefundInvoiceTest.php @@ -100,7 +100,7 @@ class RefundInvoiceTest extends \PHPUnit\Framework\TestCase private $orderMock; /** - * @var OrderInterface|\PHPUnit_Framework_MockObject_MockObject + * @var InvoiceInterface|\PHPUnit_Framework_MockObject_MockObject */ private $invoiceMock; @@ -186,6 +186,7 @@ protected function setUp() ->getMockForAbstractClass(); $this->invoiceMock = $this->getMockBuilder(InvoiceInterface::class) + ->setMethods(['getId']) ->disableOriginalConstructor() ->getMockForAbstractClass(); @@ -239,6 +240,9 @@ public function testOrderCreditmemo($invoiceId, $isOnline, $items, $notify, $app $this->invoiceRepositoryMock->expects($this->once()) ->method('get') ->willReturn($this->invoiceMock); + $this->invoiceMock->expects($this->once()) + ->method('getId') + ->willReturn($invoiceId); $this->orderRepositoryMock->expects($this->once()) ->method('get') ->willReturn($this->orderMock);