Skip to content

Commit 468cbec

Browse files
ENGCOM-7723: Fix shipping address id getter misspelling #28810
- Merge Pull Request #28810 from kodubovik/magento2:bug/shipping-address-id-getter-misspelling - Merged commits: 1. 4793b6e 2. e2933a9
2 parents 735579d + e2933a9 commit 468cbec

File tree

2 files changed

+61
-4
lines changed

2 files changed

+61
-4
lines changed

app/code/Magento/Sales/Model/ResourceModel/Order/Handler/Address.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
use Magento\Sales\Model\Order;
1010
use Magento\Sales\Model\ResourceModel\Attribute;
1111

12-
/**
13-
* Class Address
14-
*/
1512
class Address
1613
{
1714
/**
@@ -69,7 +66,7 @@ public function process(Order $order)
6966
$attributesForSave[] = 'billing_address_id';
7067
}
7168
$shippingAddress = $order->getShippingAddress();
72-
if ($shippingAddress && $order->getShippigAddressId() != $shippingAddress->getId()) {
69+
if ($shippingAddress && $order->getShippingAddressId() != $shippingAddress->getId()) {
7370
$order->setShippingAddressId($shippingAddress->getId());
7471
$attributesForSave[] = 'shipping_address_id';
7572
}

app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Handler/AddressTest.php

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,66 @@ public function testProcessShippingAddress()
133133
$this->assertEquals($this->address, $this->address->process($this->orderMock));
134134
}
135135

136+
/**
137+
* Test processing of the shipping address when shipping address id was not changed.
138+
* setShippingAddressId and saveAttribute methods must not be executed.
139+
*/
140+
public function testProcessShippingAddressNotChanged()
141+
{
142+
$this->orderMock->expects($this->exactly(2))
143+
->method('getAddresses')
144+
->willReturn([$this->addressMock]);
145+
$this->addressMock->expects($this->once())
146+
->method('save')->willReturnSelf();
147+
$this->orderMock->expects($this->once())
148+
->method('getBillingAddress')
149+
->willReturn(null);
150+
$this->orderMock->expects($this->once())
151+
->method('getShippingAddress')
152+
->willReturn($this->addressMock);
153+
$this->addressMock->expects($this->once())
154+
->method('getId')->willReturn(1);
155+
$this->orderMock->expects($this->once())
156+
->method('getShippingAddressId')
157+
->willReturn(1);
158+
$this->orderMock->expects($this->never())
159+
->method('setShippingAddressId')->willReturnSelf();
160+
$this->attributeMock->expects($this->never())
161+
->method('saveAttribute')
162+
->with($this->orderMock, ['shipping_address_id'])->willReturnSelf();
163+
$this->assertEquals($this->address, $this->address->process($this->orderMock));
164+
}
165+
166+
/**
167+
* Test processing of the billing address when billing address id was not changed.
168+
* setBillingAddressId and saveAttribute methods must not be executed.
169+
*/
170+
public function testProcessBillingAddressNotChanged()
171+
{
172+
$this->orderMock->expects($this->exactly(2))
173+
->method('getAddresses')
174+
->willReturn([$this->addressMock]);
175+
$this->addressMock->expects($this->once())
176+
->method('save')->willReturnSelf();
177+
$this->orderMock->expects($this->once())
178+
->method('getBillingAddress')
179+
->willReturn($this->addressMock);
180+
$this->orderMock->expects($this->once())
181+
->method('getShippingAddress')
182+
->willReturn(null);
183+
$this->addressMock->expects($this->once())
184+
->method('getId')->willReturn(1);
185+
$this->orderMock->expects($this->once())
186+
->method('getBillingAddressId')
187+
->willReturn(1);
188+
$this->orderMock->expects($this->never())
189+
->method('setBillingAddressId')->willReturnSelf();
190+
$this->attributeMock->expects($this->never())
191+
->method('saveAttribute')
192+
->with($this->orderMock, ['billing_address_id'])->willReturnSelf();
193+
$this->assertEquals($this->address, $this->address->process($this->orderMock));
194+
}
195+
136196
/**
137197
* Test method removeEmptyAddresses
138198
*/

0 commit comments

Comments
 (0)