Skip to content

Commit 219588b

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-99883' into 2.3-develop-pr25
2 parents 6e534ad + f343f6d commit 219588b

File tree

4 files changed

+140
-2
lines changed

4 files changed

+140
-2
lines changed

app/code/Magento/Sales/Model/AdminOrder/Create.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,9 @@ public function initFromOrder(\Magento\Sales\Model\Order $order)
516516
/* Check if we edit guest order */
517517
$session->setCustomerId($order->getCustomerId() ?: false);
518518
$session->setStoreId($order->getStoreId());
519+
if ($session->getData('reordered')) {
520+
$this->getQuote()->setCustomerGroupId($order->getCustomerGroupId());
521+
}
519522

520523
/* Initialize catalog rule data with new session values */
521524
$this->initRuleData();
@@ -773,7 +776,7 @@ public function getCustomerCompareList()
773776
public function getCustomerGroupId()
774777
{
775778
$groupId = $this->getQuote()->getCustomerGroupId();
776-
if (!$groupId) {
779+
if (!isset($groupId)) {
777780
$groupId = $this->getSession()->getCustomerGroupId();
778781
}
779782

app/code/Magento/Sales/Test/Mftf/Section/AdminOrderItemsOrderedSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
<element name="productNameColumn" type="text" selector=".edit-order-table .col-product .product-title"/>
2525
<element name="productNameOptions" type="text" selector=".edit-order-table .col-product .item-options"/>
2626
<element name="productName" type="text" selector="#order-items_grid span[id*=order_item]"/>
27+
<element name="productPrice" type="text" selector=".order-tables tbody td:nth-child({{row}}) .price" parameterized="true"/>
2728
<element name="productNameOptionsLink" type="text" selector="//table[contains(@class, 'edit-order-table')]//td[contains(@class, 'col-product')]//a[text() = '{{var1}}']" parameterized="true"/>
2829
<element name="productSkuColumn" type="text" selector=".edit-order-table .col-product .product-sku-block"/>
2930
<element name="productTotal" type="text" selector="#order-items_grid .col-total"/>

app/code/Magento/Sales/Test/Mftf/Test/AdminReorderWithCatalogPriceTest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@
6161
</actionGroup>
6262
<!--Reorder-->
6363
<click selector="{{AdminOrderDetailsMainActionsSection.reorder}}" stepKey="clickReorder"/>
64+
<!--Verify order item row-->
65+
<waitForElementVisible selector="{{AdminOrderItemsOrderedSection.productPrice('2')}}" stepKey="waitOrderItemPriceToBeVisible"/>
66+
<see selector="{{AdminOrderItemsOrderedSection.productPrice('2')}}" userInput="${{AdminOrderSimpleProductWithCatalogRule.subtotal}}" stepKey="seeOrderItemPrice"/>
6467
<!--Verify totals on Order page-->
6568
<scrollTo selector="{{AdminOrderFormTotalSection.grandTotal}}" stepKey="scrollToOrderGrandTotal"/>
6669
<waitForElementVisible selector="{{AdminOrderFormTotalSection.total('Subtotal')}}" stepKey="waitOrderSubtotalToBeVisible"/>

app/code/Magento/Sales/Test/Unit/Model/AdminOrder/CreateTest.php

Lines changed: 132 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
use Magento\Sales\Model\AdminOrder\Create;
2727
use Magento\Sales\Model\AdminOrder\Product;
2828
use Magento\Quote\Model\QuoteFactory;
29+
use Magento\Sales\Model\Order;
30+
use Magento\Sales\Model\Order\Item as OrderItem;
31+
use Magento\Sales\Model\ResourceModel\Order\Item\Collection as ItemCollection;
32+
use Magento\Store\Api\Data\StoreInterface;
2933
use PHPUnit_Framework_MockObject_MockObject as MockObject;
3034

3135
/**
@@ -86,6 +90,14 @@ class CreateTest extends \PHPUnit\Framework\TestCase
8690
*/
8791
private $dataObjectHelper;
8892

93+
/**
94+
* @var Order|MockObject
95+
*/
96+
private $orderMock;
97+
98+
/**
99+
* @inheritdoc
100+
*/
89101
protected function setUp()
90102
{
91103
$this->formFactory = $this->createPartialMock(FormFactory::class, ['create']);
@@ -101,9 +113,29 @@ protected function setUp()
101113

102114
$this->sessionQuote = $this->getMockBuilder(\Magento\Backend\Model\Session\Quote::class)
103115
->disableOriginalConstructor()
104-
->setMethods(['getQuote', 'getStoreId', 'getCustomerId'])
116+
->setMethods(
117+
[
118+
'getQuote',
119+
'getStoreId',
120+
'getCustomerId',
121+
'setData',
122+
'setCurrencyId',
123+
'setCustomerId',
124+
'setStoreId',
125+
'setCustomerGroupId',
126+
'getData',
127+
'getStore',
128+
'getUseOldShippingMethod',
129+
]
130+
)
105131
->getMock();
106132

133+
$storeMock = $this->getMockBuilder(StoreInterface::class)
134+
->setMethods(['getId'])
135+
->getMockForAbstractClass();
136+
$this->sessionQuote->method('getStore')
137+
->willReturn($storeMock);
138+
107139
$this->customerMapper = $this->getMockBuilder(Mapper::class)
108140
->setMethods(['toFlatArray'])
109141
->disableOriginalConstructor()
@@ -114,6 +146,24 @@ protected function setUp()
114146
->disableOriginalConstructor()
115147
->getMock();
116148

149+
$this->orderMock = $this->getMockBuilder(Order::class)
150+
->disableOriginalConstructor()
151+
->setMethods(
152+
[
153+
'getEntityId',
154+
'getId',
155+
'setReordered',
156+
'getReordered',
157+
'getOrderCurrencyCode',
158+
'getCustomerGroupId',
159+
'getItemsCollection',
160+
'getShippingAddress',
161+
'getBillingAddress',
162+
'getCouponCode',
163+
]
164+
)
165+
->getMock();
166+
117167
$objectManagerHelper = new ObjectManagerHelper($this);
118168
$this->adminOrderCreate = $objectManagerHelper->getObject(
119169
Create::class,
@@ -312,4 +362,85 @@ public function testGetCustomerCart()
312362

313363
$this->assertEquals($cartResult, $this->adminOrderCreate->getCustomerCart());
314364
}
365+
366+
public function testInitFromOrder()
367+
{
368+
$this->sessionQuote->method('getData')
369+
->with('reordered')
370+
->willReturn(true);
371+
372+
$address = $this->createPartialMock(
373+
Address::class,
374+
[
375+
'setSameAsBilling',
376+
'setCustomerAddressId',
377+
'getSameAsBilling',
378+
]
379+
);
380+
$address->method('getSameAsBilling')
381+
->willReturn(true);
382+
$address->method('setCustomerAddressId')
383+
->willReturnSelf();
384+
385+
$quote = $this->getMockBuilder(Quote::class)
386+
->disableOriginalConstructor()
387+
->setMethods(
388+
[
389+
'setCustomerGroupId',
390+
'getBillingAddress',
391+
'getShippingAddress',
392+
'isVirtual',
393+
'collectTotals',
394+
]
395+
)
396+
->getMock();
397+
398+
$quote->method('getBillingAddress')
399+
->willReturn($address);
400+
$quote->method('getShippingAddress')
401+
->willReturn($address);
402+
403+
$this->sessionQuote
404+
->method('getQuote')
405+
->willReturn($quote);
406+
407+
$orderItem = $this->createPartialMock(
408+
OrderItem::class,
409+
[
410+
'getParentItem',
411+
'getQtyOrdered',
412+
'getQtyShipped',
413+
'getQtyInvoiced',
414+
]
415+
);
416+
$orderItem->method('getQtyOrdered')
417+
->willReturn(2);
418+
$orderItem->method('getParentItem')
419+
->willReturn(false);
420+
421+
$iterator = new \ArrayIterator([$orderItem]);
422+
423+
$itemCollectionMock = $this->getMockBuilder(ItemCollection::class)
424+
->disableOriginalConstructor()
425+
->setMethods(['getIterator'])
426+
->getMock();
427+
$itemCollectionMock->method('getIterator')
428+
->willReturn($iterator);
429+
430+
$this->orderMock->method('getItemsCollection')
431+
->willReturn($itemCollectionMock);
432+
$this->orderMock->method('getReordered')
433+
->willReturn(false);
434+
$this->orderMock->method('getShippingAddress')
435+
->willReturn($address);
436+
$this->orderMock->method('getBillingAddress')
437+
->willReturn($address);
438+
$this->orderMock->method('getCouponCode')
439+
->willReturn(true);
440+
441+
$quote->expects($this->once())
442+
->method('setCustomerGroupId');
443+
444+
$this->adminOrderCreate->initFromOrder($this->orderMock);
445+
}
315446
}

0 commit comments

Comments
 (0)