Skip to content

Commit 371da06

Browse files
committed
[BUGFIX] - Fixed integrstion and static test failures
1 parent 91182c7 commit 371da06

File tree

3 files changed

+50
-69
lines changed

3 files changed

+50
-69
lines changed

app/code/Magento/OfflineShipping/Model/Carrier/Tablerate.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,7 @@ public function collectRates(RateRequest $request)
136136
$freeQty += $item->getQty() * ($child->getQty() - $freeShipping);
137137
}
138138
}
139-
} elseif (
140-
($item->getFreeShipping() || $item->getAddress()->getFreeShipping()) &&
139+
} elseif (($item->getFreeShipping() || $item->getAddress()->getFreeShipping()) &&
141140
($item->getFreeShippingMethod() == null || $item->getFreeShippingMethod() &&
142141
$item->getFreeShippingMethod() == 'tablerate_bestway')
143142
) {

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

Lines changed: 47 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -20,96 +20,78 @@
2020

2121
Bootstrap::getInstance()->loadArea('frontend');
2222
$objectManager = Bootstrap::getObjectManager();
23-
$productRepository = $objectManager
24-
->create(ProductRepositoryInterface::class);
25-
$firstProduct = $objectManager->create(Product::class);
26-
$firstProduct->setTypeId(Type::TYPE_SIMPLE)
27-
->setCategoryIds([3])
28-
->setId(123)
23+
24+
$simpleProduct = $objectManager->create(Product::class)
25+
->setTypeId(Type::TYPE_SIMPLE)
2926
->setAttributeSetId(4)
30-
->setName('First Test Product For TableRate')
31-
->setSku('tableRate-1')
32-
->setPrice(40)
33-
->setTaxClassId(0)
34-
->setMetaTitle('meta title')
35-
->setMetaKeyword('meta keyword')
36-
->setMetaDescription('meta description')
27+
->setWebsiteIds([1])
28+
->setName('Simple Product')
29+
->setSku('simple-1')
30+
->setPrice(10)
3731
->setVisibility(Visibility::VISIBILITY_BOTH)
3832
->setStatus(Status::STATUS_ENABLED)
39-
->setStockData(
40-
[
41-
'qty' => 100,
42-
'is_in_stock' => 1,
43-
'manage_stock' => 1,
44-
]
45-
)
33+
->setCategoryIds([2])
34+
->setStockData([
35+
'use_config_manage_stock' => 1,
36+
'qty' => 100,
37+
'is_qty_decimal' => 0,
38+
'is_in_stock' => 1,
39+
])
4640
->save();
4741

48-
/** @var ProductRepositoryInterface $productRepository */
49-
$firstProduct = $productRepository->save($firstProduct);
42+
$productRepository = $objectManager->get(ProductRepositoryInterface::class);
43+
$productRepository->save($simpleProduct);
5044

51-
$secondProduct = $objectManager->create(Product::class);
52-
$secondProduct->setTypeId(Type::TYPE_VIRTUAL)
53-
->setCategoryIds([6])
54-
->setId(124)
45+
$virtualProduct = $objectManager->create(Product::class)
46+
->setTypeId(Type::TYPE_VIRTUAL)
5547
->setAttributeSetId(4)
56-
->setName('Second Test Product For TableRate')
57-
->setSku('tableRate-2')
58-
->setPrice(20)
59-
->setTaxClassId(0)
60-
->setMetaTitle('meta title')
61-
->setMetaKeyword('meta keyword')
62-
->setMetaDescription('meta description')
48+
->setWebsiteIds([1])
49+
->setName('Virtual Product')
50+
->setSku('virtual-1')
51+
->setPrice(10)
6352
->setVisibility(Visibility::VISIBILITY_BOTH)
6453
->setStatus(Status::STATUS_ENABLED)
65-
->setStockData(
66-
[
67-
'qty' => 100,
68-
'is_in_stock' => 1,
69-
'manage_stock' => 1,
70-
]
71-
)
54+
->setCategoryIds([2])
55+
->setStockData([
56+
'use_config_manage_stock' => 1,
57+
'qty' => 100,
58+
'is_qty_decimal' => 0,
59+
'is_in_stock' => 1,
60+
])
7261
->save();
7362

74-
/** @var ProductRepositoryInterface $productRepository */
75-
$secondProduct = $productRepository->save($secondProduct);
63+
$productRepository->save($virtualProduct);
7664

7765
$addressData = include __DIR__ . '/address_data.php';
78-
$billingAddress = $objectManager->create(
79-
Address::class,
80-
['data' => $addressData]
81-
);
66+
$billingAddress = $objectManager->create(Address::class, ['data' => $addressData]);
8267
$billingAddress->setAddressType('billing');
8368

84-
$shippingAddress = $objectManager->create(
85-
Address::class,
86-
['data' => $addressData]
87-
);
88-
$shippingAddress->setAddressType('shipping');
89-
90-
$store = $objectManager
91-
->get(StoreManagerInterface::class)
92-
->getStore();
69+
/** @var Address $shippingAddress */
70+
$shippingAddress = clone $billingAddress;
71+
$shippingAddress->setId(null)->setAddressType('shipping');
9372

9473
/** @var Quote $quote */
9574
$quote = $objectManager->create(Quote::class);
96-
$quote->setCustomerIsGuest(true)
97-
->setStoreId($store->getId())
75+
$quote
76+
->setCustomerIsGuest(true)
77+
->setStoreId($objectManager->get(StoreManagerInterface::class)->getStore()->getId())
9878
->setReservedOrderId('quoteWithVirtualProduct')
9979
->setBillingAddress($billingAddress)
100-
->setShippingAddress($shippingAddress);
80+
->setShippingAddress($shippingAddress)
81+
->setCustomerEmail('test@test.magento.com');
82+
$quote->addProduct($simpleProduct);
83+
$quote->addProduct($virtualProduct);
84+
85+
$quote->getShippingAddress()->setShippingMethod('tablerate_bestway');
10186
$quote->getPayment()->setMethod('checkmo');
102-
$quote->addProduct($firstProduct);
103-
$quote->addProduct($secondProduct);
104-
$quote->setIsMultiShipping(0);
87+
$quote->collectTotals();
10588

10689
$quoteRepository = $objectManager->get(CartRepositoryInterface::class);
10790
$quoteRepository->save($quote);
10891

10992
/** @var QuoteIdMask $quoteIdMask */
110-
$quoteIdMask = $objectManager
111-
->create(QuoteIdMaskFactory::class)
112-
->create();
113-
$quoteIdMask->setQuoteId($quote->getId())
93+
$quoteIdMask = $objectManager->create(QuoteIdMaskFactory::class)->create();
94+
$quoteIdMask
95+
->setQuoteId($quote->getId())
11496
->setDataChanges(true)
11597
->save();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@
3030
$productRepository = Bootstrap::getObjectManager()
3131
->get(ProductRepositoryInterface::class);
3232
try {
33-
$product = $productRepository->get('tableRate-1', false, null, true);
33+
$product = $productRepository->get('simple-1', false, null, true);
3434
$productRepository->delete($product);
3535
} catch (NoSuchEntityException $e) {
3636
//Product already removed
3737
}
3838

3939
try {
40-
$customDesignProduct = $productRepository->get('tableRate-2', false, null, true);
40+
$customDesignProduct = $productRepository->get('virtual-1', false, null, true);
4141
$productRepository->delete($customDesignProduct);
4242
} catch (NoSuchEntityException $e) {
4343
//Product already removed

0 commit comments

Comments
 (0)