19 private $gripPoolMock;
24 private $attributeMock;
30 $this->model = new \Magento\Sales\Model\Order\Invoice\Plugin\AddressUpdate(
42 $orderMock = $this->createPartialMock(
43 \
Magento\Sales\Model\Order::class,
44 [
'hasInvoices',
'getBillingAddress',
'getShippingAddress',
'getInvoiceCollection',
'getId']
47 $shippingMock = $this->createMock(\
Magento\Sales\Model\
Order\Address::class);
48 $shippingMock->expects($this->once())->method(
'getId')->willReturn($shippingId);
50 $billingMock = $this->createMock(\
Magento\Sales\Model\
Order\Address::class);
51 $billingMock->expects($this->once())->method(
'getId')->willReturn($billingId);
54 $invoiceMock = $this->createMock(\
Magento\Sales\Model\
Order\Invoice::class);
55 $invoiceCollectionMock->expects($this->once())->method(
'getItems')->willReturn([$invoiceMock]);
57 $orderMock->expects($this->once())->method(
'hasInvoices')->willReturn(
true);
58 $orderMock->expects($this->once())->method(
'getBillingAddress')->willReturn($billingMock);
59 $orderMock->expects($this->once())->method(
'getShippingAddress')->willReturn($shippingMock);
60 $orderMock->expects($this->once())->method(
'getInvoiceCollection')->willReturn($invoiceCollectionMock);
61 $orderMock->expects($this->once())->method(
'getId')->willReturn($orderId);
63 $invoiceMock->expects($this->once())->method(
'getBillingAddressId')->willReturn(
null);
64 $invoiceMock->expects($this->once())->method(
'getShippingAddressId')->willReturn(
null);
65 $invoiceMock->expects($this->once())->method(
'setShippingAddressId')->with($shippingId)->willReturnSelf();
66 $invoiceMock->expects($this->once())->method(
'setBillingAddressId')->with($billingId)->willReturnSelf();
68 $this->attributeMock->expects($this->once())
69 ->method(
'saveAttribute')
70 ->with($invoiceMock, [
'billing_address_id',
'shipping_address_id'])
73 $this->gripPoolMock->expects($this->once())->method(
'refreshByOrderId')->with($orderId)->willReturnSelf();
75 $this->model->afterProcess(