|
5 | 5 | */
|
6 | 6 | declare(strict_types=1);
|
7 | 7 |
|
8 |
| -$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); |
| 8 | +use Magento\Bundle\Model\Option; |
| 9 | +use Magento\Bundle\Model\Product\Type as BundleProductType; |
| 10 | +use Magento\Catalog\Api\ProductRepositoryInterface; |
| 11 | +use Magento\Checkout\Model\Cart; |
| 12 | +use Magento\Checkout\Model\Session; |
| 13 | +use Magento\Quote\Api\CartManagementInterface; |
| 14 | +use Magento\Quote\Model\Quote\Address; |
| 15 | +use Magento\Quote\Model\Quote\Payment; |
| 16 | +use Magento\Quote\Model\QuoteManagement; |
| 17 | +use Magento\TestFramework\Helper\Bootstrap; |
9 | 18 |
|
10 | 19 | require __DIR__ . '/two_bundle_products_with_separate_shipping.php';
|
11 | 20 | $addressData = include __DIR__ . '/../../../Magento/Sales/_files/address_data.php';
|
12 | 21 |
|
13 |
| -$billingAddress = $objectManager->create(\Magento\Quote\Model\Quote\Address::class, ['data' => $addressData]); |
| 22 | +$objectManager = Bootstrap::getObjectManager(); |
| 23 | +$billingAddress = $objectManager->create(Address::class, ['data' => $addressData]); |
14 | 24 | $billingAddress->setAddressType('billing');
|
15 | 25 |
|
16 | 26 | $shippingAddress = clone $billingAddress;
|
17 |
| -$shippingAddress->setId(null)->setAddressType('shipping')->setShippingMethod('flatrate_flatrate'); |
| 27 | +$shippingAddress->setId(null) |
| 28 | + ->setAddressType('shipping') |
| 29 | + ->setShippingMethod('flatrate_flatrate'); |
18 | 30 |
|
19 |
| -/** @var \Magento\Quote\Model\Quote\Payment $payment */ |
20 |
| -$payment = $objectManager->create(\Magento\Quote\Model\Quote\Payment::class); |
| 31 | +/** @var Payment $payment */ |
| 32 | +$payment = $objectManager->create(Payment::class); |
21 | 33 | $payment->setMethod('checkmo');
|
22 | 34 |
|
23 |
| -/** @var \Magento\Catalog\Model\ProductRepository $productRepository */ |
24 |
| -$productRepository = $objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class); |
| 35 | +/** @var ProductRepositoryInterface $productRepository */ |
| 36 | +$productRepository = $objectManager->create(ProductRepositoryInterface::class); |
25 | 37 |
|
26 | 38 | $bundleProduct = $productRepository->get('bundle-product-separate-shipping-1');
|
27 | 39 | $bundleProduct2 = $productRepository->get('bundle-product-separate-shipping-2');
|
|
30 | 42 | $bundleProduct2->getId() => [11, 13],
|
31 | 43 | ];
|
32 | 44 |
|
33 |
| -/** @var $cart \Magento\Checkout\Model\Cart */ |
34 |
| -$cart = $objectManager->create(\Magento\Checkout\Model\Cart::class); |
| 45 | +/** @var Cart $cart */ |
| 46 | +$cart = $objectManager->create(Cart::class); |
35 | 47 |
|
36 | 48 | foreach ([$bundleProduct, $bundleProduct2] as $product) {
|
37 | 49 |
|
38 |
| - /** @var $typeInstance \Magento\Bundle\Model\Product\Type */ |
| 50 | + /** @var BundleProductType $typeInstance */ |
39 | 51 | $typeInstance = $product->getTypeInstance();
|
40 | 52 | $typeInstance->setStoreFilter($product->getStoreId(), $product);
|
41 | 53 | $optionCollection = $typeInstance->getOptionsCollection($product);
|
42 | 54 |
|
43 | 55 | $bundleOptions = [];
|
44 | 56 | $bundleOptionsQty = [];
|
45 | 57 | $optionsData = [];
|
| 58 | + |
| 59 | + /** @var Option $option */ |
46 | 60 | foreach ($optionCollection as $option) {
|
47 |
| - /** @var $option \Magento\Bundle\Model\Option */ |
48 | 61 | $selectionsCollection = $typeInstance->getSelectionsCollection([$option->getId()], $product);
|
49 | 62 | $selectionIds = $selectionProducts[$product->getId()];
|
50 | 63 | $selectionsCollection->addIdFilter($selectionIds);
|
|
73 | 86 | ->setReservedOrderId('order_bundle_separately_shipped')
|
74 | 87 | ->setBillingAddress($billingAddress)
|
75 | 88 | ->setShippingAddress($shippingAddress)
|
76 |
| - ->setCheckoutMethod(\Magento\Quote\Api\CartManagementInterface::METHOD_GUEST) |
| 89 | + ->setCheckoutMethod(CartManagementInterface::METHOD_GUEST) |
77 | 90 | ->setPayment($payment);
|
78 | 91 | $cart->save();
|
79 | 92 |
|
80 |
| -/** @var \Magento\Quote\Model\QuoteManagement $quoteManager */ |
81 |
| -$quoteManager = $objectManager->get(\Magento\Quote\Model\QuoteManagement::class); |
| 93 | +/** @var QuoteManagement $quoteManager */ |
| 94 | +$quoteManager = $objectManager->get(QuoteManagement::class); |
82 | 95 | $orderId = $quoteManager->placeOrder($cart->getQuote()->getId());
|
83 | 96 |
|
84 |
| -$objectManager->removeSharedInstance(\Magento\Checkout\Model\Session::class); |
| 97 | +$objectManager->removeSharedInstance(Session::class); |
0 commit comments