Skip to content

Commit 2ce542d

Browse files
committed
ACP2E-2213: Loading order through repository loads the order multiple times from DB
1 parent 4d205c8 commit 2ce542d

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

app/code/Magento/Sales/Test/Unit/Model/Order/ShippingBuilderTest.php

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77

88
namespace Magento\Sales\Test\Unit\Model\Order;
99

10-
use Magento\Sales\Model\OrderFactory;
10+
use Magento\Sales\Api\Data\OrderInterface;
1111
use Magento\Sales\Api\Data\ShippingInterfaceFactory;
1212
use Magento\Sales\Api\Data\TotalInterfaceFactory;
13+
use Magento\Sales\Model\OrderFactory;
1314
use Magento\Sales\Model\Order\ShippingBuilder;
1415
use PHPUnit\Framework\MockObject\MockObject;
1516
use PHPUnit\Framework\TestCase;
@@ -37,16 +38,38 @@ class ShippingBuilderTest extends TestCase
3738
private $totalFactory;
3839

3940
/**
40-
* @return void
41+
* @inheirtDoc
4142
*/
4243
protected function setUp(): void
4344
{
4445
$this->orderFactory = $this->getMockBuilder(OrderFactory::class)
46+
->disableOriginalConstructor()
4547
->getMock();
4648
$this->shippingFactory = $this->getMockBuilder(ShippingInterfaceFactory::class)
49+
->disableOriginalConstructor()
4750
->getMock();
4851
$this->totalFactory = $this->getMockBuilder(TotalInterfaceFactory::class)
52+
->disableOriginalConstructor()
4953
->getMock();
5054
$this->shippingBuilder = new ShippingBuilder($this->orderFactory, $this->shippingFactory, $this->totalFactory);
5155
}
56+
57+
/**
58+
* Test for case when order is provided instead of order_id
59+
*
60+
* @return void
61+
*/
62+
public function testCreateWithOrder() : void
63+
{
64+
$order = $this->getMockBuilder(OrderInterface::class)
65+
->getMockForAbstractClass();
66+
$this->shippingBuilder->setOrder($order);
67+
$order->expects($this->any())
68+
->method('getEntityId')
69+
->willReturn(1);
70+
$this->orderFactory->expects($this->never())
71+
->method('create');
72+
73+
$this->shippingBuilder->create();
74+
}
5275
}

app/code/Magento/Sales/Test/Unit/Model/OrderRepositoryTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ private function getOrderExtensionMock(): MockObject
270270
$mockBuilder
271271
->addMethods(
272272
[
273+
'setShippingAssignments',
273274
'getShippingAssignments',
274275
'setAppliedTaxes',
275276
'setConvertingFromQuote',

0 commit comments

Comments
 (0)