Skip to content

Commit 6c9de3f

Browse files
author
Stanislav Idolov
committed
MAGETWO-53792: Build stabilization for PR
1 parent 24076a8 commit 6c9de3f

File tree

1 file changed

+33
-26
lines changed

1 file changed

+33
-26
lines changed

dev/tests/integration/testsuite/Magento/Sales/_files/order_info.php

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
);
1212

1313
/** @var $product \Magento\Catalog\Model\Product */
14-
$product = $objectManager->create('Magento\Catalog\Model\Product');
14+
$product = $objectManager->create(\Magento\Catalog\Model\Product::class);
1515
$product->setTypeId('virtual')
1616
->setId(1)
1717
->setAttributeSetId(4)
@@ -31,62 +31,69 @@
3131

3232
$addressData = include __DIR__ . '/address_data.php';
3333

34-
$billingAddress = $objectManager->create('Magento\Quote\Model\Quote\Address', ['data' => $addressData]);
34+
$billingAddress = $objectManager->create(\Magento\Quote\Model\Quote\Address::class, ['data' => $addressData]);
3535
$billingAddress->setAddressType('billing');
3636

3737
$shippingAddress = clone $billingAddress;
3838
$shippingAddress->setId(null)->setAddressType('shipping');
3939
$shippingAddress->setShippingMethod('flatrate_flatrate');
4040

4141
/** @var $quote \Magento\Quote\Model\Quote */
42-
$quote = $objectManager->create('Magento\Quote\Model\Quote');
43-
$quote->setCustomerIsGuest(
44-
true
45-
)->setStoreId(
46-
$objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore()->getId()
47-
)->setReservedOrderId(
48-
'100000001'
49-
)->setBillingAddress(
50-
$billingAddress
51-
)->setShippingAddress(
52-
$shippingAddress
53-
)->addProduct(
54-
$product,
55-
10
56-
);
42+
$quote = $objectManager->create(\Magento\Quote\Model\Quote::class);
43+
$quote->setCustomerEmail('admin@example.com');
44+
$quote->setCustomerIsGuest(true);
45+
$quote->setStoreId($objectManager->get(\Magento\Store\Model\StoreManagerInterface::class)->getStore()->getId());
46+
$quote->setReservedOrderId('100000001');
47+
$quote->setBillingAddress($billingAddress);
48+
$quote->setShippingAddress($shippingAddress);
5749
$quote->getPayment()->setMethod('checkmo');
5850
$quote->getShippingAddress()->setShippingMethod('flatrate_flatrate');
59-
$quote->save();
60-
6151
$quote->getShippingAddress()->setCollectShippingRates(true);
6252
$quote->getShippingAddress()->collectShippingRates();
63-
$quote->collectTotals();
64-
$quote->save();
6553

66-
$quote->setCustomerEmail('admin@example.com');
67-
$quoteManagement = $objectManager->create('\Magento\Quote\Api\CartManagementInterface');
54+
/** @var \Magento\Quote\Api\CartRepositoryInterface $quoteRepository */
55+
$quoteRepository = $objectManager->create(\Magento\Quote\Api\CartRepositoryInterface::class);
56+
$quoteRepository->save($quote);
57+
58+
/** @var \Magento\Quote\Api\Data\CartItemInterfaceFactory $cartItemFactory */
59+
$cartItemFactory = $objectManager->get(\Magento\Quote\Api\Data\CartItemInterfaceFactory::class);
60+
61+
/** @var \Magento\Quote\Api\Data\CartItemInterface $cartItem */
62+
$cartItem = $cartItemFactory->create();
63+
$cartItem->setQty(10);
64+
$cartItem->setQuoteId($quote->getId());
65+
$cartItem->setSku($product->getSku());
66+
$cartItem->setProductType(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE);
67+
68+
/** @var \Magento\Quote\Api\CartItemRepositoryInterface $cartItemRepository */
69+
$cartItemRepository = $objectManager->get(\Magento\Quote\Api\CartItemRepositoryInterface::class);
70+
$cartItemRepository->save($cartItem);
71+
72+
/** @var \Magento\Quote\Api\CartManagementInterface $quoteManagement */
73+
$quoteManagement = $objectManager->create(\Magento\Quote\Api\CartManagementInterface::class);
6874

75+
$quote = $quoteRepository->get($quote->getId());
6976
$order = $quoteManagement->submit($quote, ['increment_id' => '100000001']);
7077

7178
/** @var $item \Magento\Sales\Model\Order\Item */
7279
$item = $order->getAllItems()[0];
7380

7481
/** @var \Magento\Sales\Model\Order\InvoiceFactory $invoiceFactory */
75-
$invoiceFactory = $objectManager->get('Magento\Sales\Api\InvoiceManagementInterface');
82+
$invoiceFactory = $objectManager->get(\Magento\Sales\Api\InvoiceManagementInterface::class);
7683

7784
/** @var $invoice \Magento\Sales\Model\Order\Invoice */
7885
$invoice = $invoiceFactory->prepareInvoice($order, [$item->getId() => 10]);
7986
$invoice->register();
8087
$invoice->save();
8188

8289
/** @var \Magento\Sales\Model\Order\CreditmemoFactory $creditmemoFactory */
83-
$creditmemoFactory = $objectManager->get('Magento\Sales\Model\Order\CreditmemoFactory');
90+
$creditmemoFactory = $objectManager->get(\Magento\Sales\Model\Order\CreditmemoFactory::class);
8491
$creditmemo = $creditmemoFactory->createByInvoice($invoice, ['qtys' => [$item->getId() => 5]]);
8592

8693
foreach ($creditmemo->getAllItems() as $creditmemoItem) {
8794
//Workaround to return items to stock
8895
$creditmemoItem->setBackToStock(true);
8996
}
9097

91-
$creditmemoManagement = $objectManager->create('Magento\Sales\Api\CreditmemoManagementInterface');
98+
$creditmemoManagement = $objectManager->create(\Magento\Sales\Api\CreditmemoManagementInterface::class);
9299
$creditmemoManagement->refund($creditmemo);

0 commit comments

Comments
 (0)