Skip to content

Commit 249748c

Browse files
committed
MAGETWO-61095: When attempting to place a reorder after a product is disabled, product still gets added to the cart
1 parent c9f050a commit 249748c

File tree

5 files changed

+49
-9
lines changed

5 files changed

+49
-9
lines changed

dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,13 +216,11 @@
216216
$product->setOptions($options);
217217

218218
/** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepositoryFactory */
219-
$productRepositoryFactory = $objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class);
220-
$productRepositoryFactory->save($product);
219+
$productRepository = $objectManager->get(\Magento\Catalog\Api\ProductRepositoryInterface::class);
220+
$productRepository->save($product);
221221

222222
$categoryLinkManagement->assignProductToCategories(
223223
$product->getSku(),
224224
[2]
225225
);
226-
227-
$productRepositoryFactory->getById(1, false, null, true);
228226
$productRepositoryFactory->get('simple', false, null, true);

dev/tests/integration/testsuite/Magento/Quote/Model/QuoteTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ public function testReserveOrderId()
428428

429429
/**
430430
* Test to verify that disabled product cannot be added to cart
431-
* @magentoDataFixture Magento/Quote/_files/disabled_product.php
431+
* @magentoDataFixture Magento/Quote/_files/is_not_salable_product.php
432432
*/
433433
public function testAddedProductToQuoteIsSalable()
434434
{

dev/tests/integration/testsuite/Magento/Quote/_files/disabled_product.php renamed to dev/tests/integration/testsuite/Magento/Quote/_files/is_not_salable_product.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,5 @@
3636
->setHasOptions(true);
3737

3838
/** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepositoryFactory */
39-
$productRepositoryFactory = $objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class);
39+
$productRepositoryFactory = $objectManager->get(\Magento\Catalog\Api\ProductRepositoryInterface::class);
4040
$productRepositoryFactory->save($product);
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
/** @var $objectManager \Magento\TestFramework\ObjectManager */
8+
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
9+
$product = $objectManager->create(\Magento\Catalog\Model\Product::class);
10+
$product->isObjectNew(true);
11+
$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE)
12+
->setId(99)
13+
->setAttributeSetId(4)
14+
->setWebsiteIds([1])
15+
->setName('Simple Product')
16+
->setSku('simple-99')
17+
->setPrice(10)
18+
->setWeight(1)
19+
->setShortDescription("Short description")
20+
->setTaxClassId(0)
21+
->setDescription('Description with <b>html tag</b>')
22+
->setMetaTitle('meta title')
23+
->setMetaKeyword('meta keyword')
24+
->setMetaDescription('meta description')
25+
->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
26+
->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
27+
->setStockData(
28+
[
29+
'use_config_manage_stock' => 1,
30+
'qty' => 100,
31+
'is_qty_decimal' => 0,
32+
'is_in_stock' => 1,
33+
]
34+
)
35+
->setCanSaveCustomOptions(true)
36+
->setHasOptions(true);
37+
38+
/** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepositoryFactory */
39+
$productRepositoryFactory = $objectManager->get(\Magento\Catalog\Api\ProductRepositoryInterface::class);
40+
$productRepositoryFactory->save($product);

dev/tests/integration/testsuite/Magento/SalesRule/Model/Quote/Address/Total/ShippingTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ protected function setUp()
3131
}
3232

3333
/**
34+
* @magentoAppIsolation enabled
3435
* @magentoDataFixture Magento/SalesRule/_files/rule_free_shipping_by_product_weight.php
35-
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
36+
* @magentoDataFixture Magento/Quote/_files/is_salable_product.php
3637
*/
3738
public function testRuleByProductWeightWithFreeShipping()
3839
{
@@ -45,8 +46,9 @@ public function testRuleByProductWeightWithFreeShipping()
4546
}
4647

4748
/**
49+
* @magentoAppIsolation enabled
4850
* @magentoDataFixture Magento/SalesRule/_files/rule_free_shipping_by_product_weight.php
49-
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
51+
* @magentoDataFixture Magento/Quote/_files/is_salable_product.php
5052
*/
5153
public function testRuleByProductWeightWithoutFreeShipping()
5254
{
@@ -94,7 +96,7 @@ private function prepareQuote($itemQty)
9496
$cartItem = $cartItemFactory->create();
9597
$cartItem->setQuoteId($cartId);
9698
$cartItem->setQty($itemQty);
97-
$cartItem->setSku('simple');
99+
$cartItem->setSku('simple-99');
98100
$cartItem->setProductType(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE);
99101

100102
$this->itemRepository->save($cartItem);

0 commit comments

Comments
 (0)