19 private $shippingAssignmentProcessorMock;
24 private $cartExtensionFactoryMock;
39 private $extensionAttributeMock;
44 private $shippingAssignmentMock;
48 $this->cartExtensionFactoryMock = $this->createPartialMock(
52 $this->shippingAssignmentProcessorMock = $this->createMock(
55 $this->quoteMock = $this->createMock(\
Magento\
Quote\Model\Quote::class);
56 $this->addressMock = $this->createMock(\
Magento\
Quote\Model\
Quote\Address::class);
57 $this->extensionAttributeMock = $this->createPartialMock(
59 [
'setShippingAssignments']
62 $this->shippingAssignmentMock = $this->createMock(\
Magento\
Quote\Api\Data\ShippingAssignmentInterface::class);
64 $this->quoteMock->expects($this->once())->method(
'getExtensionAttributes')->willReturn(
null);
65 $this->cartExtensionFactoryMock
66 ->expects($this->once())
68 ->willReturn($this->extensionAttributeMock);
69 $this->shippingAssignmentProcessorMock
70 ->expects($this->once())
72 ->willReturn($this->shippingAssignmentMock);
73 $this->extensionAttributeMock
74 ->expects($this->once())
75 ->method(
'setShippingAssignments')
76 ->with([$this->shippingAssignmentMock])
78 $this->quoteMock->expects($this->once())->method(
'setExtensionAttributes')->with($this->extensionAttributeMock);
79 $this->model = new \Magento\Quote\Model\ShippingAddressAssignment(
80 $this->cartExtensionFactoryMock,
81 $this->shippingAssignmentProcessorMock
88 $addressMock = $this->createMock(\
Magento\
Quote\Api\Data\AddressInterface::class);
89 $this->quoteMock->expects($this->once())->method(
'getShippingAddress')->willReturn($addressMock);
90 $addressMock->expects($this->once())->method(
'getId')->willReturn($addressId);
91 $this->addressMock->expects($this->once())->method(
'setSameAsBilling')->with(1);
92 $this->quoteMock->expects($this->once())->method(
'removeAddress')->with($addressId);
93 $this->quoteMock->expects($this->once())->method(
'setShippingAddress')->with($this->addressMock);
94 $this->model->setAddress($this->quoteMock, $this->addressMock,
true);
99 $addressMock = $this->createMock(\
Magento\
Quote\Api\Data\AddressInterface::class);
100 $this->quoteMock->expects($this->once())->method(
'getShippingAddress')->willReturn($addressMock);
101 $addressMock->expects($this->once())->method(
'setSameAsBilling')->with(0)->willReturnSelf();
102 $this->quoteMock->expects($this->once())->method(
'setShippingAddress')->with($addressMock);
103 $this->model->setAddress($this->quoteMock, $this->addressMock,
false);
testSetAddressUseForShippingFalse()
testSetAddressUseForShippingTrue()