![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/dev/tests/integration/testsuite/Magento/Sales/_files/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ use Magento\Catalog\Api\ProductRepositoryInterface; use Magento\Catalog\Model\Product; use Magento\Catalog\Model\Product\Attribute\Source\Status; use Magento\Catalog\Model\Product\Visibility; use Magento\CatalogInventory\Api\Data\StockItemInterface; use Magento\Quote\Api\CartRepositoryInterface; use Magento\Quote\Model\Quote; use Magento\Quote\Model\Quote\Address; use Magento\Store\Model\StoreManagerInterface; use Magento\TestFramework\Helper\Bootstrap; /** @var \Magento\TestFramework\ObjectManager $objectManager */ $objectManager = Bootstrap::getObjectManager(); /** @var Product $product */ $product = $objectManager->create(Product::class); $product->setTypeId('simple') ->setAttributeSetId(4) ->setName('Simple Product') ->setSku('simple001') ->setPrice(10) ->setQty(100) ->setVisibility(Visibility::VISIBILITY_BOTH) ->setStatus(Status::STATUS_ENABLED); /** @var StockItemInterface $stockItem */ $stockItem = $objectManager->create(StockItemInterface::class); $stockItem->setQty(100) ->setIsInStock(true); $extensionAttributes = $product->getExtensionAttributes(); $extensionAttributes->setStockItem($stockItem); /** @var ProductRepositoryInterface $productRepository */ $productRepository = $objectManager->get(ProductRepositoryInterface::class); $product = $productRepository->save($product); $addressData = include __DIR__ . '/address_data.php'; $billingAddress = $objectManager->create(Address::class, ['data' => $addressData]); $billingAddress->setAddressType('billing'); $shippingAddress = clone $billingAddress; $shippingAddress->setId(null) ->setAddressType('shipping'); /** @var \Magento\Store\Api\Data\StoreInterface $store */ $store = $objectManager->get(StoreManagerInterface::class) ->getStore(); /** @var Quote $quote */ $quote = $objectManager->create(Quote::class); $quote->setCustomerIsGuest(false) ->setCustomerEmail('[email protected]') ->setStoreId($store->getId()) ->setReservedOrderId('2000000001') ->setBillingAddress($billingAddress) ->setShippingAddress($shippingAddress) ->addProduct($product); $quote->getPayment() ->setMethod('checkmo'); $quote->getShippingAddress() ->setShippingMethod('flatrate_flatrate') ->setCollectShippingRates(true); $quote->collectTotals(); /** @var CartRepositoryInterface $quoteRepository */ $quoteRepository = $objectManager->get(CartRepositoryInterface::class); $quoteRepository->save($quote);