|
4 | 4 | * See COPYING.txt for license details.
|
5 | 5 | */
|
6 | 6 |
|
7 |
| -// @codingStandardsIgnoreFile |
8 |
| - |
9 |
| -require __DIR__ . '/../../../Magento/Store/_files/core_fixturestore.php'; |
10 |
| - |
11 |
| -$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); |
12 |
| - |
13 |
| -$objectManager->get(\Magento\Framework\Indexer\IndexerRegistry::class) |
14 |
| - ->get('catalogsearch_fulltext') |
| 7 | +use Magento\TestFramework\Helper\Bootstrap as BootstrapHelper; |
| 8 | +use Magento\Framework\Indexer\IndexerRegistry; |
| 9 | +use Magento\CatalogSearch\Model\Indexer\Fulltext as FulltextIndexer; |
| 10 | +use Magento\Catalog\Model\Product; |
| 11 | +use Magento\Sales\Model\Order\Address as OrderAddress; |
| 12 | +use Magento\Sales\Model\Order\Payment as OrderPayment; |
| 13 | +use Magento\Sales\Model\Order\Item as OrderItem; |
| 14 | +use Magento\Sales\Model\Order; |
| 15 | +use Magento\Store\Model\StoreManagerInterface; |
| 16 | + |
| 17 | +require __DIR__ . '/../../Store/_files/core_fixturestore.php'; |
| 18 | + |
| 19 | +$objectManager = BootstrapHelper::getObjectManager(); |
| 20 | + |
| 21 | +$objectManager->get(IndexerRegistry::class) |
| 22 | + ->get(FulltextIndexer::INDEXER_ID) |
15 | 23 | ->reindexAll();
|
16 | 24 |
|
17 |
| -require __DIR__ . '/../../../Magento/Catalog/_files/product_simple_duplicated.php'; |
18 |
| -/** @var \Magento\Catalog\Model\Product $product */ |
| 25 | +require __DIR__ . '/../../Catalog/_files/product_simple_duplicated.php'; |
| 26 | +/** @var Product $product */ |
19 | 27 |
|
20 | 28 | $addressData = include __DIR__ . '/address_data.php';
|
21 | 29 |
|
22 |
| -$billingAddress = $objectManager->create(\Magento\Sales\Model\Order\Address::class, ['data' => $addressData]); |
| 30 | +$billingAddress = $objectManager->create(OrderAddress::class, ['data' => $addressData]); |
23 | 31 | $billingAddress->setAddressType('billing');
|
24 | 32 |
|
25 | 33 | $shippingAddress = clone $billingAddress;
|
26 | 34 | $shippingAddress->setId(null)->setAddressType('shipping');
|
27 | 35 |
|
28 |
| -$payment = $objectManager->create(\Magento\Sales\Model\Order\Payment::class); |
| 36 | +$payment = $objectManager->create(OrderPayment::class); |
29 | 37 | $payment->setMethod('checkmo');
|
30 | 38 |
|
31 |
| -/** @var \Magento\Sales\Model\Order\Item $orderItem */ |
32 |
| -$orderItem = $objectManager->create(\Magento\Sales\Model\Order\Item::class); |
| 39 | +/** @var OrderItem $orderItem */ |
| 40 | +$orderItem = $objectManager->create(OrderItem::class); |
33 | 41 | $orderItem->setProductId($product->getId())->setQtyOrdered(2);
|
34 | 42 |
|
35 |
| -/** @var \Magento\Sales\Model\Order $order */ |
36 |
| -$order = $objectManager->create(\Magento\Sales\Model\Order::class); |
37 |
| -$order->setIncrementId( |
38 |
| - '100000004' |
39 |
| -)->setState( |
40 |
| - \Magento\Sales\Model\Order::STATE_PROCESSING |
41 |
| -)->setStatus( |
42 |
| - $order->getConfig()->getStateDefaultStatus(\Magento\Sales\Model\Order::STATE_PROCESSING) |
43 |
| -)->setSubtotal( |
44 |
| - 100 |
45 |
| -)->setBaseSubtotal( |
46 |
| - 100 |
47 |
| -)->setCustomerIsGuest( |
48 |
| - true |
49 |
| -)->setCustomerEmail( |
50 |
| - |
51 |
| -)->setBillingAddress( |
52 |
| - $billingAddress |
53 |
| -)->setShippingAddress( |
54 |
| - $shippingAddress |
55 |
| -)->setStoreId( |
56 |
| - $objectManager->get(\Magento\Store\Model\StoreManagerInterface::class)->getStore('fixturestore')->getId() |
57 |
| -)->addItem( |
58 |
| - $orderItem |
59 |
| -)->setPayment( |
60 |
| - $payment |
61 |
| -); |
62 |
| -$order->save(); |
| 43 | +/** @var Order $order */ |
| 44 | +$order = $objectManager->create(Order::class); |
| 45 | +$order->setIncrementId('100000004') |
| 46 | + ->setState(Order::STATE_PROCESSING) |
| 47 | + ->setStatus($order->getConfig()->getStateDefaultStatus(Order::STATE_PROCESSING)) |
| 48 | + ->setSubtotal(100) |
| 49 | + ->setBaseSubtotal(100) |
| 50 | + ->setCustomerIsGuest(true) |
| 51 | + -> setCustomerEmail( '[email protected]') |
| 52 | + ->setBillingAddress($billingAddress) |
| 53 | + ->setShippingAddress($shippingAddress) |
| 54 | + ->setStoreId($objectManager->get(StoreManagerInterface::class)->getStore('fixturestore')->getId()) |
| 55 | + ->addItem($orderItem) |
| 56 | + ->setPayment($payment) |
| 57 | + ->save(); |
0 commit comments